Convert HTML to PDF using URL in Java with Aspose.PDF for Java - Styles and images are not rendered correctly
We are planning to convert webpage url to PDF as per our requirement. For example
we have web page url : https://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html
This url ends with an extension .html. So when an end user replaces .html with .pdf then we would like to show the PDF version of that webpage.
When we go through the ASPOSE API, we came to know that it will possible using below code snippet using java:
// Create and initialize URL
URL oracleURL = new URL("https://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html");
// Get web page as input stream
InputStream is = oracleURL.openStream();
// Initialize HTML load options
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// Load stream into Document object
Document pdfDocument = new Document(is, htmloptions);
// Save output as PDF format
pdfDocument.save("HTML-to-PDF.pdf");
Also tried by adding base path as shown below:
String basePath = "basePath";
HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);
But, when tried with our web page urls we observed that styles, images are missing in generated pdf and also content is overlapped when tried with base path settings.
We would like to connect with your technical team once to check about our requirement will be achievable with ASPOSE API or not ? else are we missing anything ?
Thank you.