We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to Single Page TIFF using Aspose.PDF for Java - Out of Memory and Drawing exceptions

During an attempt to convert pdf document to single page tiff files we get the following stacktrace:
class com.aspose.pdf.internal.ms.System.l5if:
java.lang.RuntimeException:
Error in processing graphic objects —>
java.lang.RuntimeException:
Error in processing graphic objects
— End of inner exception stack trace —
com.aspose.pdf.devices.lI.lI(Unknown Source)
com.aspose.pdf.devices.TiffDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.DocumentDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.DocumentDevice.process(Unknown Source)
com.stormed.common.utils.ImageUtils.pdfToTiffAspose(ImageUtils.java:204)
com.stormed.ocr.tesseract.PdfConvertTiff.getTiffs(PdfConvertTiff.java:25)
com.stormed.ocr.tesseract.Ocr.ocrextracted(Ocr.java:30)
com.stormed.ocr.OcrEpisodeII_Tesseract.ocr(OcrEpisodeII_Tesseract.java:22)
com.stormed.ocr.OcrMain.(OcrMain.java:94)
com.stormed.ocr.common.OcrBuilder.run(OcrBuilder.java:49)
com.stormed.proxy.AppRunner.run(AppRunner.java:21)
com.stormed.proxy.ProxyMain.runApp(ProxyMain.java:223)
com.stormed.proxy.ProxyMain.lambda$main$0(ProxyMain.java:115)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
at com.aspose.pdf.devices.lI.lI(Unknown Source)
at com.aspose.pdf.devices.TiffDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.DocumentDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.DocumentDevice.process(Unknown Source)
at com.stormed.common.utils.ImageUtils.pdfToTiffAspose(ImageUtils.java:204)
at com.stormed.ocr.tesseract.PdfConvertTiff.getTiffs(PdfConvertTiff.java:25)
at com.stormed.ocr.tesseract.Ocr.ocrextracted(Ocr.java:30)
at com.stormed.ocr.OcrEpisodeII_Tesseract.ocr(OcrEpisodeII_Tesseract.java:22)
at com.stormed.ocr.OcrMain.(OcrMain.java:94)
at com.stormed.ocr.common.OcrBuilder.run(OcrBuilder.java:49)
at com.stormed.proxy.AppRunner.run(AppRunner.java:21)
at com.stormed.proxy.ProxyMain.runApp(ProxyMain.java:223)
at com.stormed.proxy.ProxyMain.lambda$main$0(ProxyMain.java:115)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException:
Error in processing graphic objects at com.aspose.pdf.internal.l2h.l0h.lf(Unknown Source)
at com.aspose.pdf.internal.l2h.l0h.lt(Unknown Source)
at com.aspose.pdf.internal.l2h.lu.lf(Unknown Source)
at com.aspose.pdf.internal.l2h.lu.lI(Unknown Source)
… 17 more Caused by:
class com.aspose.pdf.exceptions.DrawStringException —>
java.lang.OutOfMemoryError: Java heap space
— End of inner exception stack trace —
com.aspose.pdf.internal.l10t.le.lI(Unknown Source)
com.aspose.pdf.internal.l10t.le.lI(Unknown Source)
com.aspose.pdf.internal.l3k.lI.lI(Unknown Source)
com.aspose.pdf.internal.l2h.l0h.lf(Unknown Source)
com.aspose.pdf.internal.l2h.l0h.lt(Unknown Source)
com.aspose.pdf.internal.l2h.lu.lf(Unknown Source)
com.aspose.pdf.internal.l2h.lu.lI(Unknown Source)
com.aspose.pdf.devices.lI.lI(Unknown Source)
com.aspose.pdf.devices.TiffDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.DocumentDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.DocumentDevice.process(Unknown Source)
com.stormed.common.utils.ImageUtils.pdfToTiffAspose(ImageUtils.java:204)
com.stormed.ocr.tesseract.PdfConvertTiff.getTiffs(PdfConvertTiff.java:25)
com.stormed.ocr.tesseract.Ocr.ocrextracted(Ocr.java:30)
com.stormed.ocr.OcrEpisodeII_Tesseract.ocr(OcrEpisodeII_Tesseract.java:22)
com.stormed.ocr.OcrMain.(OcrMain.java:94)
com.stormed.ocr.common.OcrBuilder.run(OcrBuilder.java:49)
com.stormed.proxy.AppRunner.run(AppRunner.java:21)
com.stormed.proxy.ProxyMain.runApp(ProxyMain.java:223)
com.stormed.proxy.ProxyMain.lambda$main$0(ProxyMain.java:115)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748) at com.aspose.pdf.internal.l10t.le.lI(Unknown Source)
at com.aspose.pdf.internal.l10t.le.lI(Unknown Source) at com.aspose.pdf.internal.l3k.lI.lI(Unknown Source)
… 21 more Caused by: java.lang.OutOfMemoryError: Java heap space

Any insight into why the drawing class above or just side effect of the heap space error?

Code Snipit:
try {
pdfDocument = new Document(inputFilePath);
imageStream = new FileOutputStream(outputFilePath);

		Resolution resolution = new Resolution(DEFAULT_DPI_RESOLUTION);   // abstract resolution that seems to correlate to dots per inch (DPI)

		TiffSettings tiffSettings = new TiffSettings();
		tiffSettings.setCompression(compressingType);
		tiffSettings.setDepth(colorDepth);
		tiffSettings.setSkipBlankPages(false);

		TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
		**tiffDevice.process((IDocument) pdfDocument, imageStream);**
		pdfDocument.close();
	} finally {
		if(pdfDocument != null ){
			pdfDocument.close();
		}
		if(imageStream != null) {
			imageStream.close();
		}

Attached Sample File.
SMH.PC.00000001.pdf (1.2 MB)

@dmckinney

We have been able to observe similar exception in our environment using Aspose.PDF for Java 20.5 and logged it as PDFJAVA-39474 in our issue tracking system. We will look into reasons behind this issue and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

@dmckinney

The attached PDF has high resolution image inside (more than 200 millions of pixels) that in process of conversion requires at least 3G of Heap space memory. Please increase Java Heap space by using JVM command line option: -Xmx3G. In case you still face any issue, please let us know. The earlier logged ticket is closed now.