PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 6:30 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Nov 23, 2009 8:36 pm 
Offline

Joined: Mon Nov 23, 2009 8:01 pm
Posts: 6
I've already seen the recomendation to change to migradoc, but am stuck with sharp for now and can't convert.

I've created a multi-page pdf and it looks just fine. Now I need to go back and add "x of xx" pages in the footer.

Does anyone have an example of doing that??


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 24, 2009 10:18 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
csnyder wrote:
Does anyone have an example of doing that??

I don't.

Just keep references to all pages you create and before saving, loop through them and add the text.
Should be simple, even without sample.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 27, 2009 5:38 pm 
Offline

Joined: Mon Nov 23, 2009 8:01 pm
Posts: 6
should be simple, but When I try to loop back thru the pages, I keep getting an error message about:
"An XGraphics object already exists for this page and must be disposed before a new one can be created."
and I can't find out how to get around this error.

After creating the multi-page document, I then try to loop thru it page by page, and need to get the xgraphics object for each page, but I keep getting this error message.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 30, 2009 1:46 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
When you're done drawing the page call
Code:
gfx.Dispose();


Then you will be able to call
Code:
XGraphics.FromPdfPage(page);

later to add the page number.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 02, 2009 3:25 pm 
Offline

Joined: Mon Nov 23, 2009 8:01 pm
Posts: 6
Sigh, so simple that I couldn't see the problem. Thanks for the answer. Now its simple.

chuck


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 04, 2009 10:14 am 
Offline
Supporter

Joined: Fri May 15, 2009 3:28 pm
Posts: 96
I never understood why a PdfPage object doesnt have a XGraphics Property?

i.e. Page1.Gfx.DrawString()?

Having to dispose and then create new graphics objects for a page is surely inefficient?

Mike


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 07, 2009 12:19 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
mikesowerbutts wrote:
Having to dispose and then create new graphics objects for a page is surely inefficient?

You can keep the XGraphics object.
PDFsharp only prevents creation of a second XGraphics object. Therefore you must dispose it or keep a reference to it.

The creation of a new one shouldn't matter (e. g. no file operation involved).

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 376 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