0
先生,我將實現用於將PDF轉換爲jpeg的模塊。起初,我可以成功創建一頁PDF。然後,我使用 How to create image from PDF using PDFBox in JAVA 給出的參考來構建這個模型。Java Android Eclipse堆空間注意運行pdf到jps轉換文件模塊
當涉及到建設項目和compling,Java堆空間occcurs。下面
是我的代碼
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();
}
}
下面是我的日食INI部分增加可用到Eclipse堆大小
--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