logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Wednesday, July 10, 2019 5:04:21 AM(UTC)
 
Originally Posted by: Jan-Willem Go to Quoted Post
Thanks for your response.

These examples all concern a PdfDocument. But my list contains PataGames.Pdf.Net.PdfPage objects. How can I create a Pdf document out of them?



Where did you get them?
It seems you should use ImportPages instead. Like shown in the examples I have provided.

Just open one document, create new document and than import pages from one to another.



Concerning your code...

1. Why do you insert zero indexed page object only?
Code:
myNewPDF.Pages[i].PageObjects.Add(myPDFPagesList[i].PageObjects[0]);

2. You cannot insert the same object into multiple pages. You should clone it at least.
Code:
myNewPDF.Pages[i].PageObjects.Add(myPDFPagesList[i].PageObjects[0].Clone());


In any case, I believe that the ImportPages are more suitable for you.
Jan-Willem Posted: Tuesday, July 9, 2019 10:37:16 AM(UTC)
 
Thanks for your response.

These examples all concern a PdfDocument. But my list contains PataGames.Pdf.Net.PdfPage objects. How can I create a Pdf document out of them?

Paul Rayman Posted: Saturday, July 6, 2019 10:36:45 AM(UTC)
 
What is a "GetPDFPagesList"?
It seems you can just use the ImportPages method to copy pages from one document to another.
https://forum.patagames....merge-multiple-pdf-files
https://forum.patagames....plit-PDF-in-C--or-VB-Net
Jan-Willem Posted: Saturday, July 6, 2019 10:29:01 AM(UTC)
 
How can I create an new Pdf from an C# List of PataGames.Pdf.Net.PdfPage objects.

I've the folowing code:

Code:
       List<PdfPage> myPDFPagesList = GetPDFPagesList(list);
       string myFulPathAndFileNameWithExtension = Path.Combine(myFullExtractionPath, myFileNAme + ".pdf");

            using (PdfDocument myNewPDF = PdfDocument.CreateNew())
            {

                for (int i = 0; i < myPDFPagesList.Count; i++)
                {
                    Patagames.Pdf.FS_SIZEF myNewSize = new Patagames.Pdf.FS_SIZEF(myPDFPagesList[i].Width, myPDFPagesList[i].Width);
                    myNewPDF.Pages.InsertPageAt(i, myNewSize);
                    myNewPDF.Pages[i].PageObjects.Add(myPDFPagesList[i].PageObjects[0]);
                    myNewPDF.Pages[i].GenerateContent(); 
                }

                myNewPDF.Save(myFulPathAndFileNameWithExtension, SaveFlags.NoIncremental);
            }


The pages are blanc. Also it seems complex since I already have PdfPages

Thanks in advance for your help