PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 5:32 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Sep 02, 2015 2:23 pm 
Offline

Joined: Wed Sep 02, 2015 1:59 pm
Posts: 2
Hello,

I'm using PdfSharp to convert a bmp into a pdf file in a C# program.
So I have my image as a Bitmap object, and my pdf as a PdfPage object.
My goal is to have a pdf page size as close as possible to my image.

I'm using the PdfPage Width and Height Properties and set them to my Bitmap Width and Height.
Except Bitmap uses pixels as unit and PdfPage uses drawing.Xunit.

My question is the following : How can I convert pixels to drawing.Xunit ?

I'm using PdfSharp dll version v2.0.50727, GDI+


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 02, 2015 2:38 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
PDF files have no pixels. Specify the desired size when drawing the image (using XUnit).

See also:
http://stackoverflow.com/a/32089469/162529

ehryon wrote:
My question is the following: How can I convert pixels to drawing.Xunit?
The are 72 points per inch. How many pixels per inch there are in your bitmap depends solely on your bitmap. Conversion will be simple if you know the DPI of your bitmap.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 02, 2015 2:48 pm 
Offline

Joined: Wed Sep 02, 2015 1:59 pm
Posts: 2
I've already searched a bit around the web, but apparently not enough or not with enough attention.

With the DPI information I should be able to figure it out. I just need to get my bitmap DPI which is ... another thing.

Thank you for your quick, and very useful reply !


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

All times are UTC


Who is online

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