<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Is the DocumentFactory able to convert *.docx to *.pdf?</title><link>https://answers.axonivy.com/questions/3919/is-the-documentfactory-able-to-convert-docx-to-pdf</link><description>&lt;p&gt;For a curernt application, we have the requirement to convert &lt;em&gt;.docx and &lt;/em&gt;.doc files to a *.pdf file and append a page. Can this be done with the DocumentFactory or do we have to implement this by utilizing other tools?&lt;/p&gt;
&lt;p&gt;The Aspose API should be able to do that, but I couldn't find an example on the Jira page for the DocumentFactory.&lt;/p&gt;
&lt;p&gt;Edit - due to a &lt;a href="https://answers.axonivy.com/questions/2526/aspose-evaluation-only-message"&gt;related question&lt;/a&gt;, I could answer it myself. Both scenarios are possible by utilizing Aspose directly.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        Document doc = new Document("C:\\Users\\m.hoffmann\\Documents\\Die Kultur im Sudetenland.docx");
        DocumentBuilder docBuilder = new DocumentBuilder(doc);
        docBuilder.moveToDocumentEnd();
        docBuilder.insertBreak(BreakType.PAGE_BREAK);
        docBuilder.writeln("Dies ist ein Beispielausgabetext, welcher mit Aspose eingefügt wurde");
        docBuilder.getDocument().save("C:\\Users\\m.hoffmann\\Documents\\asposeOutputEdited.pdf", SaveFormat.PDF);
&lt;/code&gt;&lt;/pre&gt;</description><atom:link href="https://answers.axonivy.com/questions/3919/is-the-documentfactory-able-to-convert-docx-to-pdf" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 14 Aug 2019 08:41:22 -0400</lastBuildDate><item><title>Answer by Emmanuel Comba</title><link>https://answers.axonivy.com/questions/3919/is-the-documentfactory-able-to-convert-docx-to-pdf/3920</link><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is pretty simple to convert doc/docx to pdf with the DocFactory, even if it is not its "first" purpose. 
Just consider the following unit test:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    File docxToBeConverted = new File(TEST_DIRECTORY_RELATIVE_PATH + "/singleAppendedFileContinuous.docx");

    DocumentTemplate docTemplate = DocumentTemplate.withTemplate(docxToBeConverted);
    docTemplate.setOutputFormat(DocFactoryConstants.PDF_EXTENSION);
    docTemplate.setOutputName("docxConvertedToPdf");
    docTemplate.setOutputPath(TEST_DIRECTORY_RELATIVE_PATH);

    FileOperationMessage result = docTemplate.generateDocument();
    File pdfFile = result.getFiles().get(0);

    assertThat(result.isSuccess(), is(true));
    assertThat(result.getFiles(), hasSize(1));
    assertTrue(pdfFile.isFile());
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we use the ch.ivyteam.ivy.addons.docfactory.DocumentTemplate Object which gets a template for doing the mail merge. As we only give a plain doc or docx without any mergefields and data to fill, the doc or docx remains untouched during the mail merge operation and the result is only saved as PDF.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emmanuel Comba</dc:creator><pubDate>Wed, 14 Aug 2019 08:41:22 -0400</pubDate><guid>https://answers.axonivy.com/questions/3919/is-the-documentfactory-able-to-convert-docx-to-pdf/3920</guid></item></channel></rss>