Crash by add many pages to pdf

Discussions about PDF management.
Post Reply
rassekst
Posts: 15
Joined: Thu Oct 04, 2007 6:58 pm

Crash by add many pages to pdf

Post by rassekst » Mon Nov 09, 2015 2:01 pm

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

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: Crash by add many pages to pdf

Post by delbeke » Tue Nov 10, 2015 11:06 am

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");

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests