Hi Team,
I’m trying to remove all the stamps from the PDF file and able to get the stamps inside each page and trying to remove it is working fine without any issue. But at some point, it is giving me
last.mql.log:Error: #1900068: execute program failed last.mql.log:System Error: #5000001: java.lang.OutOfMemoryError: Java heap space
Is there any way we can resolve this issue. Below is the code i have used:
public void removeHeaderFooterWatermark1(Context context, String sFileNameWithPath) throws Exception
{
List iStampIds = new ArrayList();
com.aspose.pdf.facades.StampInfo[] stamps = null;
com.aspose.pdf.facades.StampInfo stampInfoDetail = null;
StampType stStampType = null;
try {
PdfContentEditor contentEditor = new PdfContentEditor();
System.out.println(“Before>>>>>>>>>>>>>>>>>>”);
//InputStream inputStream = new FileInputStream(sFileNameWithPath);
contentEditor.bindPdf(sFileNameWithPath);//path+file
for(Page page1 : contentEditor.getDocument().getPages()) {
System.out.println(“page1.getNumber()>>>>>>>>>>>>>>>>>>:”+page1.getNumber());
stamps = contentEditor.getStamps(page1.getNumber());
System.out.println(“stamps>>>>>>>>>>>>>>>>>>:”+stamps);
iStampIds = new ArrayList();
System.out.println(“stamps.length>>>>>>>>>>>>>>>>>>:”+stamps.length);
for(int i=0; i<stamps.length; i++){
stampInfoDetail = stamps[i];
stStampType = stampInfoDetail.getStampType();
if((StampType.Form).equals(stStampType)){
int iStampDetail = stampInfoDetail.getIndexOnPage();
iStampIds.add(iStampDetail);
}
}
int[] intArrDetailStamp = iStampIds.stream().filter(iDetail → iDetail != null).mapToInt(iDetail → iDetail).toArray();
//System.out.println(“Before delete Stamp>>>>>>>>>>>>>>>>>>:”+intArrDetailStamp.length);
//contentEditor.deleteStamp(page1.getNumber(), intArrDetailStamp);
System.out.println(“page1.getNumber()…1…>>>>>>>>>>>>>>>>>>:”+page1.getNumber());
}
System.out.println(“After>>>>>>>>>>>>>>>>>>”);
contentEditor.save(sFileNameWithPath);//new file
} catch (Exception ex) {
System.out.println(" ** Exception in the prigram removeHeaderFooterWatermark---->" + ex.getMessage());
ex.printStackTrace();
}
}
Please help me to resolve this