Java will convert Word documents to PDF

Foreword

This article describes how to use Word free Java components Free Spire.Doc for Java in the Java application to convert in the Word document in PDF format. Free Spire.Doc for Java in the conversion process can recognize Chinese characters and supports a rich word document elements: text boxes, headers, footers, bullets and numbering, tables, text, hyperlinks, watermark, images, shapes and so on.
Java will convert Word documents to PDF

Free Spire.Doc for Java Overview

Free Spire.Doc for Java by E-iceblue developed a free Java Word API, covering the Word document creation, editing, reading, writing, translation and printing functions, and does not rely on Microsoft Office.
Java will convert Word documents to PDF

Jar file import method

method one:

1: Download the latest Free Spire.Doc for Java package and unzip Download .

2: New Java Application and click File -> Project Structure -> Modules -> Dependencies, under the Dependencies tab interface, right click the green "+" sign, select the first option "JARs or directories ...", select package lib Spire.Doc-FE_2.7.3 Spire.Doc.jar file folder, point "OK", jar file import is successful, the successful introduction as shown below:
Java will convert Word documents to PDF
3. after completing the above steps, the new Java Class ( here I named WordtoPDF.Java), and add the code.
Java will convert Word documents to PDF

Method two:
introduced through maven. The method of introducing the reference link ( https://www.e-iceblue.cn/licensing/install-spirepdf-for-java-from-maven-repository.html )
Java will convert Word documents to PDF

Java code example Word to PDF's:

import com.spire.doc.*;
public class WordtoPDF {
    public static void main(String[] args) {

        //加载word示例文档
        Document document = new Document();
        document.loadFromFile("Sample.docx");

        //保存为PDF格式
        document.saveToFile("out/toPDF.pdf", FileFormat.PDF);

    }
}

Word documents before converting shown:
Java will convert Word documents to PDF

FIG code execution results to PDF:
Java will convert Word documents to PDF

Guess you like

Origin blog.51cto.com/14765544/2481579