PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Tue Sep 30, 2025 9:53 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Dec 17, 2012 11:24 pm 
Offline

Joined: Mon Dec 17, 2012 10:39 pm
Posts: 3
Here is a line from the PdfSharp feature list.
Quote:
One source code for drawing on a PDF page as well as in a window or on the printer

Is there any sample of code shared between system.drawing.graphics and Xgraphics?

For example a hello world where the same code could write to either a system.drawing.graphics or Xgraphics?

Did I misunderstand the feature? Please explain how to draw the same thing to system.drawing.graphics and also to a PDF without duplicating code.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 18, 2012 10:09 pm 
Offline

Joined: Mon Dec 17, 2012 10:39 pm
Posts: 3
Ah, I found the answer here.
http://www.pdfsharp.net/wiki/Graphics.ashx
Code:
XGraphics gfx = XGraphics.FromGraphics(graphics, size);


So you can't use system.drawing.graphics to draw on a PDF, but you can use XGraphics to draw on system.drawing.graphics.

My document will need to be re-written with XGraphics and transformed from 1/72 inch to 1/96 inch so it will fit on standard LETTER size. But then I could conceivably use a single function to draw a PDF, or alternatively draw the same document to a graphics context from a print event handler.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 304 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