For a curernt application, we have the requirement to convert .docx and .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?

The Aspose API should be able to do that, but I couldn't find an example on the Jira page for the DocumentFactory.

Edit - due to a related question, I could answer it myself. Both scenarios are possible by utilizing Aspose directly.

        Document doc = new Document("C:\\Users\\m.hoffmann\\Documents\\Die Kultur im Sudetenland.docx");
        DocumentBuilder docBuilder = new DocumentBuilder(doc);
        docBuilder.writeln("Dies ist ein Beispielausgabetext, welcher mit Aspose eingefĆ¼gt wurde");
        docBuilder.getDocument().save("C:\\Users\\m.hoffmann\\Documents\\asposeOutputEdited.pdf", SaveFormat.PDF);
This question is marked "community wiki".

asked 14.08.2019 at 06:13

mhoffmann's gravatar image

accept rate: 0%

edited 14.08.2019 at 07:00


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:

    File docxToBeConverted = new File(TEST_DIRECTORY_RELATIVE_PATH + "/singleAppendedFileContinuous.docx");

    DocumentTemplate docTemplate = DocumentTemplate.withTemplate(docxToBeConverted);

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

    assertThat(result.isSuccess(), is(true));
    assertThat(result.getFiles(), hasSize(1));

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.


answered 14.08.2019 at 08:41

Emmanuel%20Comba's gravatar image

Emmanuel Comba
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 14.08.2019 at 06:13

Seen: 1,204 times

Last updated: 14.08.2019 at 08:41