Pdfmake: Page size unit

Created on 15 Jul 2015  Â·  16Comments  Â·  Source: bpampuch/pdfmake

Hi

what is the unit used for page size ?

I don't find this information in the documentation.

Most helpful comment

Why is this answered? I am very confused that this is not part of the documentation.... Isn't this like THE main think when creating and printing PDF? What if I need a general page margin of 1cm (10mm)? If the unit is inches, I could easily calculate this but if it is points it depends on the monitor I am using isn't it? Why is the documentation not saying which unit this is?
Best regards

All 16 comments

Anybody? I read in #334 that margins are provided in inch, but this is definitely not true for pageSize...

pageSize: {height: 90, width: 38}

is really tiny.

I think it's strange, that these properties use different units. Did I miss a way to specify which unit is used?

On the other hand:

pageMargins: [40,60,40,60]

as used in the docs shows, that pageMargins probably aren't inches either. In fact: I can enter, whatever I want and don't see _any_ difference in the pdf...

Try,

pageSize: { width: w * 72, height: h * 72 },

 On Tuesday, September 8, 2015 8:33 PM, Nico Prediger <[email protected]> wrote:

Anybody? I read in #334 that margins are provided in inch, but this is definitely not true for pageSize...pageSize: {height: 90, width: 38}
is really tiny.I think it's strange, that these properties use different units. Did I miss a way to specify which unit is used?—
Reply to this email directly or view it on GitHub.

Thanks, that works. In pageSize as well as pageMargins...

I can get from mm to inch by multiplying with 0.0393700787, so that's what I did after reading #334, but it seems like I only get 1/72 of an inch because of $someReason ?!

Anyway, I can move on now, thank you very much.

For me it seems like 72 is dpi of the document, so size and margins units are simple pixels. This is only my suppose.

Actually sizes and margins are in points (pt)

Actually they are in TWIPS.

If you want to set the page size to 5 inch by 6 inch, set the values 5 * 72 and 6 * 72. Same with margin.

Something tells me they are not in TWIPS. Namely, a TWIP seems to be 1/1440 of an inch, and that would imply the standard page sizes given are absurdly small (see the documentation). In fact, I believe the default page size is defined as A4 in printer.js: width=595.28, height=841.89. If it were twips, this would be fractions of an inch. Knowing that the true width of the A4 standard is 8.3 inches, we would expect that to imply that 595.28/8.3=71.7 is the scaling factor (call it dpi or whatever you want). However, this is almost certainly just rounding error, and in fact, the scaling factor from inches to _insert whatever these mysterious units ACTUALLY are_ is 72 as mentioned above. In any case, I do believe that the margins use the same units, and I believe their default value is 40 on each side.

In fact you are right. It is not TWIPS, my bad. The mysterious unit is "point", as indicated in @Serios. One inch is 72 point size. Point is the unit normally used to specify font size.

It would be handy to be able to define page sizes in mm or inches for me because im am printing to a zebra printer, 72 DPI is standard monitor resolution but the printer I am using is 203DPI so I will adjust / test and report back.

"In printers' measures, there are 12 points to a pica and 6 picas in an inch. So, 12 x 6 = 72; there are 72 points in an inch. And since points and pixels are the same thing, there are 72 pixels in an inch, too. So, if you want something on screen to be 4 inches wide: 4 x 72 = 288."

https://www.dougv.com/2007/11/the-relationships-between-pixels-points-picas-dots-and-inches/

Answered.

Why is this answered? I am very confused that this is not part of the documentation.... Isn't this like THE main think when creating and printing PDF? What if I need a general page margin of 1cm (10mm)? If the unit is inches, I could easily calculate this but if it is points it depends on the monitor I am using isn't it? Why is the documentation not saying which unit this is?
Best regards

Could this get added to the documentation please?

Bueller???

How/Where are you wanting this added to the documentation? Is that something I can even do?

Use this function to convert millimeters to pdfmake points:

const MILLIMETERS_IN_INCH = 25.4;
const POINTS_IN_INCH = 72;

function mmToPoints(mm) {
  const inches = mm / MILLIMETERS_IN_INCH;
  return inches * POINTS_IN_INCH;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dgrice picture dgrice  Â·  3Comments

svenyonson picture svenyonson  Â·  3Comments

dmatesic picture dmatesic  Â·  3Comments

CharlyPoppins picture CharlyPoppins  Â·  3Comments

kamilkp picture kamilkp  Â·  3Comments