Convert Word to PDF in Java

This article will show you how to convert Word documents to PDF using Spire.Doc for Java. By using the method of doc.saveToFile(),Spire.Doc supports to convert Word document to XPS,SVG, XML, RTF, PDF etc.

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.ToPdfParameterList;

public class WordToPDF {
    public static void main(String[] args)  {

        //Create Document object
        Document doc = new Document();

        //Load the file from disk.

        //create an instance of ToPdfParameterList.
        ToPdfParameterList ppl=new ToPdfParameterList();

        //embeds full fonts by default when IsEmbeddedAllFonts is set to true.

        //set setDisableLink to true to remove the hyperlink effect for the result PDF page.
        //set setDisableLink to false to preserve the hyperlink effect for the result PDF page.

        //Set the output image quality as 40% of the original image. 80% is the default setting.

        //Save to file.