Hello,
Hi Hiren,
//source PDF file <o:p></o:p>
java.io.File file = new java.io.File("C:\\pdftest\\aspose_html_content\\aspose_html_content.html");
java.io.FileInputStream fis = new java.io.FileInputStream(file);
//System.out.println(file.exists() + "!!");
//InputStream in = resource.openStream();
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) {
}
byte[] bytes = bos.toByteArray();
//instantiate Document Object with ByteArrayInputStream while passing byte array as argument
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(doc.getPages().size());
doc.save(“C:\pdftest\aspose_html_content.pdf”);
Thanks for providing the code snippet. It worked and PDF file was generated.
Hi Hiren,
Hello,
Hi Hiren,