actionscript-3airalivepdf

Creating large pdf file with Adobe Air


I'm trying to create a pdf file using alivepdf lib with about 4000 pages and each page contains an image added by the alivepdf method addImage(). the problem is that the data takes a lot of memory because alivepdf creates the whole file in the memory before saving it to desk. so i am asking if there is a away i can open the file with each entry and add page then close it and free memory before adding the next page. thanks


Solution

  • I suggest you first use your app make many much smaller PDFs (for example each one is 400 pages, then next 400 as a new PDF, so on until all 4000 pages are done in 10 PDFs).

    When those are ready, use an external tool like PDFtk to process those files you saved to disk. It works from command prompt but you can tell AIR to run it as a NativeProcess. It accepts instructions to combine those saved files and output them as a new big one.

    Don't worry about memory, nothing is loaded into Flash. Flash itself can start the process but the merging will happen outside your app. Just wait for a big file to magically appear.