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
Asked
Active
Viewed 126 times
1
-
Maybe making multiple smaller PDFs and then use some tool (even as a NativeProcess) to combine them all into one from disk? – VC.One Apr 20 '16 at 13:23
-
wont't it overload memory when combining all the pdf files again? – Hamada Samir Apr 20 '16 at 13:36
-
I meant first use your app to make many small PDFs (eg: 400 pages) save and do next 400 as new PDF etc. When ready then use an external tool like **[PDFtk](https://www.pdflabs.com/tools/pdftk-server/)** to process the files you saved to disk. It works from command prompt but you can tell AIR to run as NativeProcess. It **[accepts instructions](https://www.pdflabs.com/docs/pdftk-cli-examples/)** to combine saved files and output as a new one. Nothing is loaded into Flash. Flash can start the process but the merging will happen outside your app. Just wait for a big file to magically appear... – VC.One Apr 20 '16 at 14:42
-
I do not know how to thank you for your help, can you please post it as an answer so i can vote it – Hamada Samir Apr 20 '16 at 14:55
-
Are you okay with starting a NativeProcess or you need a hint for that? If yes let me know so I add that part later on (I have to leave this computer soon)... – VC.One Apr 20 '16 at 15:07
-
1thanks a lot, yeah no problem with starting NativeProcess , i really appreciate your help. – Hamada Samir Apr 20 '16 at 15:10
1 Answers
1
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.

VC.One
- 14,790
- 4
- 25
- 57