Width and Height is smaller by creation from file

Product: Nodejs @pdftron/pdfnet-node
Product Version: “@pdftron/pdfnet-node”: “^9.0.0-2”,

I create the a PDF from file and try to read the width and height of the first page.
The Size is smaller than the original file. Why?

Of course I can scale it, but I don’t know how much it should be scaled.

How to read a PDF-file with original dimensions. Thx.

const pdfDoc = await PDFNet.PDFDoc.createFromFilePath('some.pdf');
const pdfPage = await pdfDoc.getPage(1);
const pdfPageBox = await pdfPage.getCropBox();
console.log('pdfPageBox', pdfPageBox);


From the code you are using, you are extracting the values of the CropBox, which is defined to be the region to which the contents of the page shall be cropped when displayed and printed. In other words, it is the width and height of the visible content regions of the page.

You mentioned that the size is smaller than the original file. How are you measuring the original file in this case?

I measure with a rule in the Acrobat Reader, but i get the size 33% smaller, then original file

The question is, how do i get the original size?
Now i scale the size to 1.333 before convert to SVG.


You can check the dimensions of the file by right clicking the properties of the and looking at the page size. for example, see the following page (Note that 1 inch is 72 points in a PDF. You can use this to scale accordingly):

You mentioned that you are converting this file to SVG. Are you doing this through the PDFTron SDK?

i know this properties, after converting i get the size smaller, it is about 33,33% smaller as original
I use pdftron API for nodejs, here is a link to example:

Could you please provide us with the input example file, along with the settings you have used to convert the PDF to SVG?

Thank you in advance.

fgb-08-13_90x70.pdf (812.2 KB)

const pdfDoc = await PDFNet.PDFDoc.createFromFilePath('path_to_pdf');
const pdfPage = await pdfDoc.getPage(1);
   // pdfPage.scale(1.333);
const pdfPageMediaBox = await pdfPage.getMediaBox();
console.log('pdfPageMediaBox', pdfPageMediaBox);

the variable pdfPageMediaBox shows the smaller size in the log , if I do not scale it. Try to scale and without

Hello, thank you for the file. I see that the Media box is defined below and to the left of the origin. You must calculate for that as well. You can use the following code to do so:

PDFDoc doc = new PDFDoc(@"fgb-08-13_90x70.pdf");
var page = doc.GetPage(1);
var H = page.GetPageHeight()/72;
var W = page.GetPageWidth() /72;

H = 2.80 in
W = 3.59 in

These values match what Adobe is outputting in the document properties Window. In addition, the converted height and width of the SVG is defined below:

width="258.6px" height="201.9px"

Are these the values you are expecting from your end, or are you expecting different ones?

3.59 inch = 344.64 pixel
2.80 inch = 268.8 pixel

in SVG is wrong, am I right?

width="258.6px" height="201.9px"

any help to my subject?

Hello Alexandr,

Apologies for the delay. Note that you will need to multiply the inch values by 72 to return the correct amount of pixels, which are very close to what is defined in the SVG:

3.59 inch * 72  = 258.5px
2.80 inch * 72 = 201.6px

Just to clarify, how are you getting the pixel values you provided?

if I use in millimetres and convert it to pixel, then I get 344.64 pixel

why do I need to use 72 not 96?


In PDF coordinates 1inch = 72 points/pixels. If we are using mm instead, you will need to convert this. It will then be 1mm = 2.83px/points. As such 91mm will equal to the same amount.

Note that this is how we convert files to SVG. Other formats like PNG or JPEG can be converted with a defined DPI using our API.