Hello,
During tests of new lib 10.6.1 we see:
Handling ConversionServiceException: ----> Exception occured while saving pages as set of images.
This is a Debug Exception. Please do not CR this Exception.
This exception is printed if the debug logs are turned on for log family DCS.
class com.aspose.pdf.internal.p391.z72: java.lang.NullPointerException —> java.lang.NullPointerException
— End of inner exception stack trace —
com.aspose.pdf.devices.z1.m1(Unknown Source)
com.aspose.pdf.devices.z1.m1(Unknown Source)
com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.PngDevice.process(Unknown Source)
com.x.PDFToPNGConverter.convert(PDFToPNGConverter.java:88)
com.x.ConversionTask.call(ConversionTask.java:49)
com.x.ConversionTask.call(ConversionTask.java:16)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
at com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.PngDevice.process(Unknown Source)
at com.x.PDFToPNGConverter.convert(PDFToPNGConverter.java:88)
at com.nortelnetworks.ims.app.dcs.servlet.fw.ConversionTask.call(ConversionTask.java:49)
at com.nortelnetworks.ims.app.dcs.servlet.fw.ConversionTask.call(ConversionTask.java:16)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.aspose.pdf.internal.p636.z1.m13(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m14(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m21(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m17(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m1(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m1(Unknown Source)
class com.aspose.pdf.internal.p391.z72: java.lang.NullPointerException —> java.lang.NullPointerException
— End of inner exception stack trace —
com.aspose.pdf.devices.z1.m1(Unknown Source)
com.aspose.pdf.devices.z1.m1(Unknown Source)
com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.PngDevice.process(Unknown Source)
com.x.PDFToPNGConverter.convert(PDFToPNGConverter.java:88)
com.x.ConversionTask.call(ConversionTask.java:49)
com.x.ConversionTask.call(ConversionTask.java:16)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
at com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.PngDevice.process(Unknown Source)
at com.x.PDFToPNGConverter.convert(PDFToPNGConverter.java:88)
at com.x.ConversionTask.call(ConversionTask.java:49)
at com.x.ConversionTask.call(ConversionTask.java:16)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.aspose.pdf.internal.p636.z1.m13(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m14(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m21(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m17(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m1(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m1(Unknown Source)
… 12 more
Caused by: class com.aspose.pdf.internal.p391.z72: java.lang.NullPointerException —> java.lang.NullPointerException
— End of inner exception stack trace —
com.aspose.pdf.devices.z1.m1(Unknown Source)
com.aspose.pdf.devices.z1.m1(Unknown Source)
com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.PngDevice.process(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.z1.m1(Unknown Source)
at com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
at com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.PngDevice.process(Unknown Source)
at com.x.PDFToPNGConverter.convert(PDFToPNGConverter.java:88) ( pngDevice.process(pages.get_Item(page), baos)
… 6 more
Caused by: java.lang.NullPointerException
at com.aspose.pdf.internal.p636.z1.m13(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m14(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m21(Unknown Source)
at com.aspose.pdf.internal.p636.z1.m17(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m1(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m1(Unknown Source)
… 12 more
Used code:
public boolean convert() throws ConversionServiceException {
prepare();//license.setLicense(getLicense());
Document.setLocalFontPaths(paths);resolution = new Resolution(dpi_Resolution);
String uploadedFile = formatUploadedFile(inputFileName);
PdfFileInfo fileInfo = new PdfFileInfo(uploadedFile);
Document pdfDocument = null;
try {
pdfDocument = new Document(uploadedFile);
}
catch (Exception e) {
handleException(e, “PDf file binding failed”);
}
PageCollection pages = pdfDocument.getPages();
int pageCount = (pages == null) ? 0 : pdfDocument.getPages().size();
if (pageCount > getPageLimit() || pageCount == 0) {
handleException(null, “Document size exceeds the set page limit or document is empty.”);
}
PngDevice pngDevice = new PngDevice(resolution);
JpegDevice jpegDevice = new JpegDevice(resolution, MIN_JPG_QUALITY);
try {
// convert pages to images
for (int page = 1; page <= pageCount; page++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String processFileName;
// Convert a particular page and save the image to stream
try {
pngDevice.process(pages.get_Item(page), baos);
//HERE!!!It’s line #88
}
catch (Exception e) {
handleException(e, “Exception occured while saving pages as set of images.”);
}
finally {
// Close the stream
baos.close();
}
byte[] pngImageInBytes = baos.toByteArray();
int pngFileSize = pngImageInBytes.length;
processFileName = formatProcessFile(page, PNG_EXTENSION);
if (pngFileSize == 0) {
if (DcsDebug.isEnabled()) {
DcsDebug.print("---------> PNG file size was zero so skipping write to file… " + processFileName,
DebugLevel.VERBOSE);
}
continue;
}
if (pngFileSize <= png_size_limit) {
writeToFile(processFileName, pngImageInBytes);
}
else {
ByteArrayOutputStream jbaos = new ByteArrayOutputStream();
try {
// Convert a particular page and save the image to stream
jpegDevice.process(pages.get_Item(page), jbaos);
}
catch (Exception e) {
// Nothing to do. We already have png stream
}
finally {
// Close the stream
jbaos.close();
}
byte[] jpgImageInBytes = jbaos.toByteArray();
int jpgFileSize = jpgImageInBytes.length;
if (jpgFileSize == 0 || pngFileSize <= (jpgFileSize + MAX_PNG_JPG_SIZE_OFFSET)) {
writeToFile(processFileName, pngImageInBytes);
}
else {
writeToFile(formatProcessFile(page, JPG_EXTENSION), jpgImageInBytes);
}
}
}
}
catch (Exception e) {
handleException(e, “Exception occured during PDf conversion.”);
}
finally {
com.aspose.pdf.MemoryCleaner.clear();
}
<span style=“font-size:11.0pt;font-family:
“Calibri”,“sans-serif”;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
minor-latin;mso-bidi-font-family:“Times New Roman”;color:#1F497D;mso-ansi-language:
EN-US;mso-fareast-language:RU;mso-bidi-language:AR-SA” lang=“EN-US”>The issue is
intermittent (90%).<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>RU</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt; font-family:"Times New Roman","serif";
}
<![endif]–>
I’ve seen similar reports about NullPointer exceptions but not sure that it is the same.
So could you please be so kind to verify is it bug or some incorrect usage of aspose lib?
Thank you in advance.
Best Regards