Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

java.lang.OutOfMemoryError: Java heap space Reading simple PDF

$
0
0
I am trying to convert a PDF pages to images just using the code from the documentation and I am getting a out of heap space error.
I have increased the JVM memory but I still get the error.

here is the code
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("input.pdf");

// Loop through all the pages of PDF file
for (int pageCount = 1; pageCount
{
// Create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream("Converted_Image" + pageCount + ".jpg");


// Create Resolution object
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);
// Create JpegDevice object where second argument indicates the quality of resultant image
com.aspose.pdf.devices.JpegDevice jpegDevice = new com.aspose.pdf.devices.JpegDevice(resolution, 100);
// Convert a particular page and save the image to stream
jpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);

// Close the stream
imageStream.close();
}



and this is the error.



Exception in thread "AgentThread: JavaAgent" java.lang.OutOfMemoryError: Java heap space
at java.lang.StringCoding.decode(StringCoding.java:505)
at java.lang.String.(String.java:241)
at java.util.jar.Manifest.parseName(Manifest.java:262)
at java.util.jar.Manifest.read(Manifest.java:216)
at java.util.jar.Manifest.(Manifest.java:62)
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:170)
at java.util.jar.JarFile.getManifest(JarFile.java:153)
at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:944)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:465)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)
at java.net.URLClassLoader.access$300(URLClassLoader.java:79)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1038)
at java.security.AccessController.doPrivileged(AccessController.java:365)
at java.net.URLClassLoader.findClass(URLClassLoader.java:429)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:677)
at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
at com.aspose.pdf.internal.p357.z2.(Unknown Source)
at com.aspose.pdf.internal.p597.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p634.z8.(Unknown Source)
at com.aspose.pdf.internal.p631.z12.m1(Unknown Source)
at com.aspose.pdf.internal.p561.z6.(Unknown Source)
at com.aspose.pdf.internal.p598.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p564.z7.m1(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.JpegDevice.processInternal(Unknown Source)
at com.aspose.pdf.devices.JpegDevice.process(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)

I am not sure if this is important but the PC running this code is not connected to the internet.

Also it is running an a IBM Notes client.

THanks

Viewing all articles
Browse latest Browse all 3131

Trending Articles