PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Problems with Column Width
http://forum.pdfsharp.com/viewtopic.php?f=2&t=1939
Page 1 of 1

Author:  daniel.medina [ Mon Mar 12, 2012 4:46 pm ]
Post subject:  Problems with Column Width

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?

Author:  daniel.medina [ Mon Mar 12, 2012 7:38 pm ]
Post subject:  Re: Problems with Column Width

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);

Author:  Thomas Hoevel [ Tue Mar 13, 2012 8:32 am ]
Post subject:  Re: Problems with Column Width

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.

Author:  daniel.medina [ Tue Mar 13, 2012 12:55 pm ]
Post subject:  Re: Problems with Column Width

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?

Author:  Thomas Hoevel [ Tue Mar 13, 2012 1:35 pm ]
Post subject:  Re: Problems with Column Width

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.

Author:  daniel.medina [ Tue Mar 13, 2012 2:08 pm ]
Post subject:  Re: Problems with Column Width

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?

Author:  Thomas Hoevel [ Tue Mar 13, 2012 3:34 pm ]
Post subject:  Re: Problems with Column Width

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.

Author:  daniel.medina [ Tue Mar 13, 2012 4:17 pm ]
Post subject:  Re: Problems with Column Width

all right, Thomas. Thanks a lot.

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/