Rank: Newbie
Groups: Registered
Joined: 7/6/2019(UTC) Posts: 4 
|
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 Edited by moderator Wednesday, July 10, 2019 5:07:53 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/6/2019(UTC) Posts: 4 
|
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?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Originally Posted by: Jan-Willem  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. Edited by user Wednesday, July 10, 2019 5:21:12 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close