I Must be missing something as there appears to be no Document.saveToPdf() function. I have double checked the documentation and it does not show there is a saveToPdf method either.
I downloaded a fresh version of aspose words yesterday so I must have the right version, the jar is called “Aspose.Words.jdk16.jar”
Currently my code is working like this:
WordExport exporter = new WordExport();
Document document = exporter.export(policy);
response.setContentType(“application/msword”);
document.save(response.getOutputStream(), SaveFormat.DOC);
However this doesn’t work as there is no “SaveFormat.PDF”:
WordExport exporter = new WordExport();
Document document = exporter.export(policy);
response.setContentType(“application/pdf”);
document.save(response.getOutputStream(), SaveFormat.PDF);
So I have tried making a test class to try to get it to work, the following results in generating a doc, but not a pdf:
Document doc = new Document()
//… add some test stuff…
doc.save(“test.doc”);
doc.save(“test.pdf”);
When it gets to the pdf it says:
java.lang.UnsupportedOperationException: Unsupported SaveFormat: .pdf
at com.aspose.words.Document.save(Document.java:912)
at com.aspose.words.Document.save(Document.java:859)
at Test2.create(Test2.java:79)
at Test2.main(Test2.java:49)
Is there some trick to it we dont know about?