Rank: Newbie
Groups: Guest
Joined: 10/26/2017(UTC) Posts: 2
|
Hi! Could you help with adding new page to existing pdf doc. When i try (outFileSpec already generated by GM pdf file) using (PdfWriter writer = new PdfWriter(outFileSpec)) { writer.AddPage(gc.Width, gc.Height, gc.DpiX, gc.DpiY); using (var gr = writer.GetGraphics()) { gr.DrawContainer(gc, 0, 0); } } after writer initialization file already empy.. BTW, its no possibility to generate this file in one loop. Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/4/2017(UTC) Posts: 43
Was thanked: 12 time(s) in 12 post(s)
|
Hi, Use PdfReader before initalizing PdfWriter in order to add the content of existing document to PdfWriter (as it creates new empty file), like in below example: Code:using (var reader = new PdfReader(sourceFilePath, dpi, dpi))
using (var writer = new PdfWriter(destinationFilePath))
{
writer.AddPage(gc.Width, gc.Height, gc.DpiX, gc.DpiY);
using (var graphics = writer.GetGraphics())
{
graphics.DrawContainer(gc, 0, 0);
}
}
Actually, new file will be created this way. Regards, Andrew Edited by user Friday, November 10, 2017 2:33:57 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 10/26/2017(UTC) Posts: 2
|
Thanks for help! Another question. Is it possible to rotate the PDF page 90 degrees? (without rasterizing ) Thanks!
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/4/2017(UTC) Posts: 43
Was thanked: 12 time(s) in 12 post(s)
|
Please try the following code: Code:using (var reader = new PdfReader(sourceFilePath))
using (var container = reader.Frames[0].GetContent())
using (var writer = new PdfWriter(destinationFilePath))
{
writer.AddPage(container.Height, container.Width);
using (var graphics = writer.GetGraphics())
{
graphics.Transform.Rotate(-90);
graphics.DrawContainer(container, 0, container.Width);
}
}
Regards, Andrew
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.