PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Mar 12, 2012 4:46 pm 
Offline

Joined: Mon Mar 12, 2012 4:34 pm
Posts: 7
Hi everybody.

I'm trying to set column width on columns from a table in a document, but i'm having some problems with the measure unit.

With another component, Aspose.Words, in this case, i can pass width in pixels. When i try to do this with MigraDoc, my columns in the PDF file are greater then i was informed. In all cases i can divide the informed value by the rendered width and in all cases i got 1.54 pixels. In other words, some convertion is done multiplying my width per 1.54.

How can I make sure that my column in PDF file have the same width in pixels that in informed on code? There is any convertion to do?


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 12, 2012 7:38 pm 
Offline

Joined: Mon Mar 12, 2012 4:34 pm
Posts: 7
I'm using this formula and solved my problem. But it's correct or it can return incorrect values in some cases???

column.Width = (pixelValue / 1.54);


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 13, 2012 8:32 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!
daniel.medina wrote:
How can I make sure that my column in PDF file have the same width in pixels that in informed on code?
PDF files have no pixels.
You can specify column width in centimeter, millimeter, inch, points (1/72 inch) and you'll get exactly what you ask for. Default unit is points.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 13, 2012 12:55 pm 
Offline

Joined: Mon Mar 12, 2012 4:34 pm
Posts: 7
Thomas Hoevel wrote:
Hi!
You can specify column width in centimeter, millimeter, inch, points (1/72 inch) and you'll get exactly what you ask for. Default unit is points.


So, there is no formula to convert pixels to points? No arithmetic ratio between point and pixel?


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 13, 2012 1:35 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
daniel.medina wrote:
So, there is no formula to convert pixels to points? No arithmetic ratio between point and pixel?
It seems the value 1.45 comes from Aspose.

Windows with Normal fonts uses 96 DPI (ratio 1.3333333), Windows with Large fonts uses 120 DPI (ratio 1.66666666667). But Windows allows user-defined values ...

So there are many different ratios, depending on the DPI value that is used for the conversion.
But PDF is vector-based and has no DPI at all. You can draw lines with a width of 0.5 or 0.25 points.

With Microsoft Word you specify the width of columns using cm, mm, in, or pt - just like you do with MigraDoc.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 13, 2012 2:08 pm 
Offline

Joined: Mon Mar 12, 2012 4:34 pm
Posts: 7
Thomas Hoevel wrote:
Windows with Normal fonts uses 96 DPI (ratio 1.3333333), Windows with Large fonts uses 120 DPI (ratio 1.66666666667). But Windows allows user-defined values ...

So there are many different ratios, depending on the DPI value that is used for the conversion.


There is any way to set DPI value for PDF creation on MigraDoc?


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 13, 2012 3:34 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
daniel.medina wrote:
There is any way to set DPI value for PDF creation on MigraDoc?
There are neither dots nor pixels in a PDF file, so setting DPI makes no sense.
You can create a converter function in order to have all calculations in one place.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 13, 2012 4:17 pm 
Offline

Joined: Mon Mar 12, 2012 4:34 pm
Posts: 7
all right, Thomas. Thanks a lot.

At first this whole thing sounds confusing, but considering the concepts of points and pixels it makes sense.


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

All times are UTC


Who is online

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