How much Time Aspose.Words for Java API takes to Convert DOC Word Document to PDF File Format? | CPU Performance

It takes 35 seconds to merge 3 DOC files into 1 DOC file and save it as PDF.

However the code to convert DOC to PDF takes 15 seconds (function doc2PdfSave)

Is it possible to cut off time for thissimple conversion?

public String doc2PdfSave(String dataDir, String fileNameNoExtension) throws Exception
{
// Create .pdf file
Document doc = new Document(dataDir + fileNameNoExtension + ".doc");
doc.save(dataDir + fileNameNoExtension + ".pdf");

// Delete .doc file
File findFile = new File(dataDir + fileNameNoExtension + ".doc");
try {
if(findFile.isFile()) {
findFile.delete();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}

return fileNameNoExtension + ".pdf";
}

Hi,


Thanks for your inquiry. Unfortunately, it is difficult to say what the problem is without the Word documents. I need these documents to reproduce the problem first on my side.

It is safe to attach files in the forum. If you attach your document here, only you and Aspose staff members can download it. Also you can send the file to my e-mail as described here:

You can also remove any sensitive information from your documents by replacing it with dummy data instead.

Once we have your documents, we’ll investigate the issue on our side and provide you more information.
Best regards,

I am attaching the DOC file which takes 15 secs to convert to PDF.

This code is run on linux server, and the java function to do the same is as specified before.

Note: I have only changed some text/images/logo with dummy data, rest of the documnet is unchanged.

Hi,


Thanks for your inquiry.

While using the latest version of Aspose.Words for Java i.e. 11.0.0, I was unable to reproduce this performance issue on my side. For me, the average DOC to PDF conversion time for three test runs was 6.82 seconds. Moreover, I would suggest you please visit the following link for downloading and using the latest version of Aspose.Words:

I hope, this will help.

Best Regards,

Details of Aspose jar which we are using:
Specification-Title: Aspose.Words for Java
Specification-Version: 10.7.0.0

This takes 7 to 10 seconds on Windows XP, however on the linux server it takes 15 to 20 secs.

Took the latest jar now: Specification-Version: 11.0.0.0
It still takes 9 - 10 on Windows XP

Hi,


Thanks for the additional information. I think, this issue is OS specific. On 64-bit Windows 7, I am observing an average of 6.82 seconds. Moreover, please note that the average speed of converting to PDF using Aspose.Words is 10 pages per second. Since your document has 62 pages, so theoretically this conversion should take 6.2 seconds.

Regarding long saving time, it is expected that saving to PDF, XPS or any other fixed page format, takes more time than saving to flow format (DOC, DOCX etc). This is because MS Word document is flow document, i.e. it does not contain any information about its layout into pages. So to convert it to PDF, Aspose.Words needs to layout it into pages. This is quite complex operation and that is why it takes more time.

Please let me know if I can be of any further assistance.

Best Regards,
DOC file used: Merge Document.doc

First approach: Merge 3 documents into 1 DOC and save it, then open merged file and save as PDF
Java code snippet:
String dataDir = "D:\\FileBackup\\TestMerge\\Merge Document.doc"; Document dstDoc = new Document(dataDir); dstDoc.save("D:\\FileBackup\\TestMerge\\Me.pdf");
Time taken: 23Feb2012_18.51.42.478 to 23Feb2012_18.52.01.540
File size: 468 KB

Second approach: Merge 3 documents to 1 DOC and save as PDF directly.
Java code snippet:
dstMasterDoc.updatePageLayout();
dstMasterDoc.save(MessageFormat.format(dataDir + fileName, 1));
Time taken is alomst 5 minutes with file size of 8MB!!

Now, I understand that the time taken in first approach is the best we can get.
Any reason why the second approach gives such poor results?
How can we make second approach better?
Are we missing something here?

Hi,


Thanks for your inquiry. I tested the first scenario and I am afraid, I was still unable to reproduce this performance issue on my side. I tested Aspose.Words for Java v11.0.0 on Windows XP with service pack 3 installed and results produced were almost identical. Moreover, I tested with both JDK 1.5 and 1.7. I have attached PDF file i.e. generated on my side here for your reference. Notice that file size is just around 460 kb.

To test the scenario mentioned in your second approach, could you please attach 3 documents you were merging into one here for testing. I will investigate the issue further and provide you more information…

Best Regards,