PDF merge using iText throws OOM error -


i trying merge 10 pdf files (~ 1000 pages each) single files using itext apis. below code merging. it's breaking oom error after 8 or 9 files. how can maximize 100 files, since desired result.

public class itext {  public static void main(string[] args) throws ioexception, documentexception{      string ifs2 = "c:\\downloads\\02.pdf";     string result = "c:\\merge\\final.pdf";     string[] starray = new string[10];      for(int = 0; i<10; i++){         starray[i]=ifs2;     }      mergefiles(starray,result, false);  }  public static void mergefiles(string[] files, string result, boolean smart) throws ioexception, documentexception {         document document = new document();         pdfcopy copy;         if (smart)             copy = new pdfsmartcopy(document, new fileoutputstream(result));         else             copy = new pdfcopy(document, new fileoutputstream(result));         document.open();          (int = 0; < files.length; i++) {             pdfreader reader = new pdfreader(files[i]);             copy.adddocument(reader);             reader.close();         }         document.close();     } 

update: tried below method inside loop. still getting error.

for (int = 0; < files.length; i++) {             randomaccesssourcefactory rasf = new randomaccesssourcefactory();             randomaccesssource ras = rasf.createbestsource(files[i]);             randomaccessfileorarray raf = new   randomaccessfileorarray(ras);             pdfreader reader = new pdfreader(raf, null);             copy.adddocument(reader);             raf.close();             reader.close();             system.out.println(i);         } 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -