This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
NotI Hill  
#1 Posted : Thursday, October 26, 2017 4:20:26 AM(UTC)
NotI Hill

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.

Andrey Semenov  
#2 Posted : Friday, October 27, 2017 12:40:25 AM(UTC)
Andrey Semenov

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

NotI Hill  
#3 Posted : Wednesday, November 8, 2017 11:52:33 PM(UTC)
NotI Hill

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!

Andrey Semenov  
#4 Posted : Friday, November 10, 2017 2:33:19 AM(UTC)
Andrey Semenov

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

Users browsing this topic
Guest (2)
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.