When I call
conversionHandler.convertToPdf(fileStream, originalFileName, pdfSaveOptions)
where fileStream was opened from a file and is not null, originalFileName is the file name and pdfSaveOptions is set with splitIntoPages=false
I get:
java.lang.NullPointerException
at com.groupdocs.conversion.converter.b.a(Converter.java:227)
at com.groupdocs.conversion.handler.ConversionHandler.convertToPdf(ConversionHandler.java:213)
What may be wrong and how to fix it?
Thanks
Hello,
We are sorry to hear that you have such issue. We have tried to reproduce the issue and we can’t, we have used such code:
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setSplitIntoPages(false);
//open file stream
File docFile = new File(config.getStoragePath() + DOC_FILE);
FileInputStream docInputStream = new FileInputStream(docFile);
//convert to pdf
ByteArrayOutputStream pdfOutputStream = conversionHandler.convertToPdf(docInputStream, “GroupDocs_Demo.doc”, pdfSaveOptions);
//save converted pdf from stream to file
File pdfFile = new File(config.getFileSavePath() + “streams/fromstream.pdf”);
pdfFile.getParentFile().mkdirs();
FileOutputStream pdfSaveStream = new FileOutputStream(pdfFile);
pdfSaveStream.write(pdfOutputStream.toByteArray());
pdfSaveStream.flush();
pdfSaveStream.close();
docInputStream.close();
If this code will not help you please share with us example of your code and document example that we can check and fix it for you.
Thank you.