Hi Paul,
Thanks for writing back.
I have tested the scenario in eclipse with the HTML files, shared over previous mentioned thread, and code execution took 15 seconds to generate the PDF file. Please check following code snippet that I have tried to test the scenario. For your reference, I have also attached an output generated by below code, and screenshot of results over our end.
public void PerformanceTest()
{
try
{
long start = System.currentTimeMillis();
System.out.println("START");
System.out.println("Read HTML File");
java.io.File file = new java.io.File(dataDir + "democo2015base.htm");
System.out.println("Create File Stream");
java.io.FileInputStream fis = new java.io.FileInputStream(file);
//System.out.println(file.exists() + "!!");
//InputStream in = resource.openStream();
System.out.println("Create Byte Array Outputstream");
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
byte[] buf = new byte[1024];
try {
for (int readNum; (readNum = fis.read(buf)) != -1;) {
bos.write(buf, 0, readNum); //no doubt here is 0
//Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
System.out.println("read " + readNum + " bytes,");
}
} catch (java.io.IOException ex) {
}
System.out.println("Create Byte Array");
byte[] bytes = bos.toByteArray();
//instantiate Document Object with ByteArrayInputStream while passing byte array as argument
System.out.println("Create PDF");
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(new java.io.ByteArrayInputStream(bytes), new com.aspose.pdf.HtmlLoadOptions());
//get the page count of PDF file
System.out.println("Output Number of Pages");
System.out.println(doc.getPages().size());
System.out.println("Save PDF");
doc.save(dataDir + "aspose_html_content.pdf");
System.out.println("END");
System.out.println("Spending time: " + (System.currentTimeMillis() - start)/1000 + "sec");
}catch(Exception ex){
}
}
Please note that it was about the CPU usage which went up-to 83% just for 1 second while code execution, whereas the complete conversion process took 15 seconds, as shared above.
Please check the screenshot in which I have highlight the button/option to upload files in new forums. Moreover, would you please share the the larger HTML file, so that we can also test the scenario in our environment.
Best Regards,
Asad Ali
aspose_html_content.pdf (119.9 KB)
Performance Results.png (37.3 KB)
Add_Attachment.png (5.2 KB)