Convert Word DOC to PDF and Convert Excel XLS to PDF using Java Code

Hi, Where can i find (or someone can provide me ) a sample to convert a word/excel doc to pdf using java api?
It will help me…
thx

Aspose.Words for Java does not support Word2Pdf conversion yet. It will be implemented later this year.
Concerning Excel2Pdf conversion please consult Aspose.Cells team on Aspose.Cells forum.
Best Reagrds,

Hello,
My employer is very interested in purchasing your product. We have been evaluating Aspose.Word for Java and have been pleased with it. However, it is critical that we be able to convert Word documents into PDF documents. What is the expected release date for this feature?
Chih Lin
Euler Hermes ACI

Hi,
Thank you for your interest. Unfortunately, implementing of the Word2Pdf feature in Aspose.Words for Java is still several months away. No exact date of release is currently available.

Hi,
Supposing this facility is available now, is it possible to get any sample code for doc/docx to PDF conversion in java.

Hi
Thanks for your request. Using latest version you can convert documents to PDF. Code is quite simple:

// Open document.
Document doc = new Document("C:\\Temp\\in.doc");
// Save as PDF.
doc.save("C:\\Temp\\out.pdf");

But you should note that upon converting document to PDF, Aspose.Words needs fonts. So if you perform conversion in Linux or other OS (not Windows) you have to specify folder where fonts are located. You can find a code example in Aspose.Words 10.0.0 release notes:
https://releases.aspose.com/words/java
Also note that 10.0.0 version is beta, so it is not recommended to use in production. We plan to release a production version in a month or so.
Best regards,

Thanks a lot!!!
But how it can be done on the fly and get the byte array. Because I don’t want to save the file on disk.

Hi
Thanks for your inquiry. You can use code like this:

// Open document.
Document doc = new Document("C:\\Temp\\in.doc");
// Save as PDF to stream.
ByteArrayOutputStream pdfSream = new ByteArrayOutputStream();
doc.save(pdfSream, SaveFormat.PDF);
// Get PDF bytes.
byte[] pdfbytes = pdfSream.toByteArray();

best regards,

Hi,
I have a word document containing some text in Chinese. Is it possible to convert this one to a PDF file. I used the above sample code and its converting the Chinese characters to ‘?’ symbols.

Hi
Thanks for your request. Could you please attach your input and output documents here for testing? We will check the issue and provide you more information.
Best regards,

I’m attaching here the zip file containing input word document and generated PDF file.

Hi
Thanks for your request. I cannot reproduce the problem with the latest version of Aspose.Words for Java (10.5.0 ). You can download the latest version from here:
https://releases.aspose.com/words/java
Best regards,

Thanks a lot… The latest jar did my job.

Hello Shuvadip,
Can you tell me which latest jar (of Aspose API) you have used for converting pdf to word in java. Can you please send me link of that jar.
Please reply. Thanx in advance.

Best Regards,
Rohit Tawde

Hello Shuvadip,
I am using code given below.


Document doc = new Document("hello.pdf");
// Save as PDF to stream.
ByteArrayOutputStream pdfSream = new ByteArrayOutputStream();
doc.save(pdfSream, SaveFormat.doc);
// Get PDF bytes.
byte[] pdfbytes = pdfSream.toByteArray();

bt “Document” does not support “.pdf” files… please help me its urgent.
Thanx in advance.

Best regards,
Rohit Tawde

Hi Rohit,

Thanks for your inquiry. First of all, we always encourage our customers to use the latest release versions of Aspose.Words as they contains newly introduced features, enhancements and fixes for issues reported earlier. I would suggest you please download/use the latest version (11.6.0) from the following link:
https://releases.aspose.com/words/java

Secondly, in case you still have problems during rendering your Word document to PDF format, please attach your input/output documents (.doc/.pdf files) here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

A post was split to a new topic: Document is not referenced to a type