Sir, I am going to implement the module for converting the pdf to jpeg. At first , I can successfully create the pdf with one page. Then , I use the reference given by How to create image from PDF using PDFBox in JAVA to construct this model.
When it comes to building up the projects and compling, java heap space occcurs.
The below is my code
protected void convertToImage(File file) {
// TODO Auto-generated method stub
if(!file.exists())
return;
try {
PDDocument document = null;
try
{
document = PDDocument.load(file);
}
catch (IOException ex)
{
System.out.println("" + ex);
}
List<PDPage>pages = document.getDocumentCatalog().getAllPages();
Iterator iter = pages.iterator();
int i =1;
String name = null;
while (iter.hasNext())
{
PDPage page = (PDPage) iter.next();
PDResources resources = page.getResources();
Map pageImages = resources.getImages();
if (pageImages != null)
{
Iterator imageIter = pageImages.keySet().iterator();
while (imageIter.hasNext()) {
String key = (String) imageIter.next();
PDXObjectImage image = (PDXObjectImage) pageImages.get(key);
image.write2file("H:\\image" + i);
i ++;
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Below is my eclipse ini section
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dfile.encoding=UTF-8
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms80m <------cannot be further increased
-Xmx512m <------cannot be further increased