Page 1 of 1

Crash by add many pages to pdf

Posted: Mon Nov 09, 2015 2:01 pm
by rassekst
Hi,

Ich have a problem with create a big pdf file.
In a directory are many (< 10000) pdf files (1,5GByte). I wil build a new file.

Code: Select all

oPDFZiel.NewPDF();

         for (int i = 1; i <= iSeiten; ++i)
         {
             oPDFPage.LoadFromFile(pagesPDF[i - 1], true);
             oPDFZiel.ClonePage(oPDFPage, 1);
             oPDFPage.CloseDocument();
        }

oPDFZiel.SaveToFile("new.pdf");
The code crash with a memory acception. In the memory are 1,5 GByte !!!

Is this the only method add pages in a file?

Best Regards

Steffen

Re: Crash by add many pages to pdf

Posted: Tue Nov 10, 2015 11:06 am
by delbeke
Hi Steffen

If you want to merge PDFs you can use MergeDocuments
https://www.gdpicture.com/guides/gdpicture/web ... ments.html

But if you need a way to control each added page, the ClonePage method is the good way

To control the memory comsuption, you can do this : Times to times, save the pdf and reload it.
Something like this


oPDFZiel.NewPDF();

for (int i = 1; i <= iSeiten; ++i)
{
oPDFPage.LoadFromFile(pagesPDF, true);
oPDFZiel.ClonePage(oPDFPage, 1);
oPDFPage.CloseDocument();
if ((i % 1000) == 0)
{
oPDFZiel.SaveToFile("new.pdf");
oPDFZiel.LoadFromFile("new.pdf", false);
}
}

oPDFZiel.SaveToFile("new.pdf");