Hello,
I am using Aspose PDF 21.3 to convert URLs to PDF. Below is my code:
URL quotationURL = new URL(quotationList.get(quotationIndex));
URLConnection urlConnection = quotationURL.openConnection();
com.aspose.pdf.Document quotationPDF = new com.aspose.pdf.Document(
urlConnection.getInputStream(),
new HtmlLoadOptions(quotationList.get(quotationIndex)));
String fileName = "Compra " + (purchaseIndex + 1) + " - Cotacao " + (quotationIndex + 1) + “.pdf”;
quotationPDF.save(OUTPUTPATH + “/” + fileName);
I am getting this error:
java.lang.NullPointerException
at com.aspose.pdf.internal.l44l.lI.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.lc.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.l0l.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.lc.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.lc.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.l0l.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.lk.lI (Unknown Source)
at com.aspose.pdf.internal.l44if.lk.lI (Unknown Source)
I have tested all variables and they are correct. Someone knows what is the problem?
@ninalecrim
We tested the scenario in our environment using following complete code snippet and did not notice any issue.
// Create and initialize URL
URL oracleURL = new URL("https://www.google.com");
// Get web page as input stream
InputStream is = oracleURL.openStream();
// Initialize HTML load options
HtmlLoadOptions htmloptions = new HtmlLoadOptions("https://www.google.com");
htmloptions.getPageInfo().setMargin(new MarginInfo(0,0,0,0));
htmloptions.isRenderToSinglePage();
// Load stream into Document object
Document pdfDocument = new Document(is, htmloptions);
// Save output as PDF format
pdfDocument.save(dataDir+ "HTML-to-PDF.pdf");
Could you please share the URL with which you are trying to generate PDF? We will test the scenario in our environment and address it accordingly.
This is one of the URLs I am using: [https://www.qualipix.com.br/moldura-interativa-32-pol-qualipix-pro32/].
I have also tested Aspose version 18.2. I am using Java 11.
@ninalecrim
I have been able to reproduce the issue. A ticket with ID PDFJAVA-40371 has been created to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.