PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:02 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: 72ppi vs 96ppi
PostPosted: Fri Dec 21, 2012 9:19 pm 
Offline

Joined: Mon Dec 17, 2012 10:39 pm
Posts: 3
I have a document I'm trying to translate from system.drawing.graphics code that prints to the printer. I would like to draw this same document to a PDF. After changing all my references from system.drawing.graphics to work with PdfSharp.Drawing.XGraphics, I notice some differences in the output.

Difference 1
The printer graphics context is 1066.6666 x 816.6666 (96ppi)
The pdf graphics context is 792 x 612 (72ppi)

Since my code is using points to draw, the graphics no longer fit on the page.
Also, the fonts and images are too small (not in the original proportions).

I can scale the graphics like so...
Code:
xGraphics.ScaleTransform(.72);
xGraphics.TranslateTransform(22, 15);


Then the graphics fit on the page, but the fonts and images are too small (not in the original proportions).

Instead of scaling the graphics I can grow the PDF size like so...
var document = new PdfSharp.Pdf.PdfDocument();
var page = document.AddPage();
page.Height = 1066.6666;
page.Width = 816.6666;
var xGraphics = PdfSharp.Drawing.XGraphics.FromPdfPage(page);

Then the graphics fit on the page, but the page is too big, and the fonts and images are still not in the original proportions.

I can re-size all my fonts, but it seems hacky using oversized fonts.
Is there an easier way to reuse code written for system.drawing.graphics?


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

All times are UTC


Who is online

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