PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 3:02 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Nov 29, 2010 8:30 pm 
Offline

Joined: Mon Nov 29, 2010 8:14 pm
Posts: 4
Hi, looking through this thread I saw how to add text to a PDF page.
viewtopic.php?f=2&t=373

I'm also opening up a number of PDF files and adding them to a single output PDF file (joining multiple PDF files together essentially). What I've found is the i have to open the input pdf file in PdfDocumentOpenMode.Import mode to add it to the output document, save it, then reopen the output document in PdfDocumentOpenMode.Modify to modify the pages to add text (a watermark) to the output pages.

This results in the double the IO to save the PDF file both times.

Is there was way i can import the page, and update date it in one operation?

Regards.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 30, 2010 10:38 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Where's the problem?

You create a new file, add a page from the imported file, and draw the watermark on the new page.
Then save the new file.

There's no double IO involved.

Look at variants 3 and 4 from the Concatenate Documents Sample.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 30, 2010 6:04 pm 
Offline

Joined: Mon Nov 29, 2010 8:14 pm
Posts: 4
Ok, I see with variants 3 & 4you use a retired page reference to supposedly make a modification to it. I didn't think if that for this operation....but does lead mento something else I found yesterday:

I add the pAge to the output document, and have found that the added page does not take the orientation correctly if it has changed from the previous page.

So if page1 is portrait when added to the output document it's portrait.
Page2 is landscape, when added to the output document it is portrait also.
I had previously found this and used the return page from pages.add to set the orientation to that of the input page. Bit when trying this today i noticed that page2 (landscape one) was converted to a square page almost, 210mm x 210mm rather the 297mm width by 210mm that is normal for a landscape a4 page.
But the reported size is correct, just in display it looks incorrect and the right hand side is cut off.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 30, 2010 9:21 pm 
Offline

Joined: Mon Nov 29, 2010 8:14 pm
Posts: 4
Here's output from the page information after adding the page to the output document.

Page added to output document as read from input document
(PdfSharp.Pdf.PdfPage newPage = outputDocument.AddPage(page);)
Page 1 Orient:Portrait Width:595.276pt Height:841.89pt Size:Undefined
NewPage 1 Orient:Portrait Width:595.276pt Height:841.89pt Size:A4

Explicitly setting orientation
(newPage.Orientation = page.Orientation;)
Page 1 Orient:Portrait Width:595.276pt Height:841.89pt Size:Undefined
NewPage 1 Orient:Portrait Width:595.276pt Height:841.89pt Size:A4

Page added to output document as read from input document
(PdfSharp.Pdf.PdfPage newPage = outputDocument.AddPage(page);)
Page 3 Orient:Landscape Width:841.89pt Height:595.276pt Size:Undefined
NewPage 3 Orient:Portrait Width:595.276pt Height:841.89pt Size:A4

Explicitly setting orientation
(newPage.Orientation = page.Orientation;)
Page 3 Orient:Landscape Width:841.89pt Height:595.276pt Size:Undefined
NewPage 3 Orient:Landscape Width:841.89pt Height:595.276pt Size:A4

But there is something happening with the viewing of that third page. The dimensions are reported as correct, but on screen the right hand side is cut off.

DLL version 1.31.1789
Dot Net 2 framework.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group