How can I find(in mm) the width and the height of a pdf page using PDFBox? Currently, I\'m using this:
System.out.println(page.getMediaBox().getHeight());
Sy
If the document is created using a different DPI than 72 then use the more general formula:
public float pt2mmForWeb72dpi(float pt) {
return pt2mm(pt,72);
}
public float pt2mmForPrint300dpi(float pt) {
return pt2mm(pt,300);
}
public float pt2mmForPrint600dpi(float pt) {
return pt2mm(pt,600);
}
public float pt2mm(float pt, float dpi) {
return pt * 25.4f / dpi;
}
You can find more at https://forums.indigorose.com/forum/indigo-rose-software/developer-s-den/13282-what-is-the-size-of-a4-in-px
A4 is a document format, as a screen image that's going to depend on the image resolution, for example an A4 document resized to:
- 72 dpi (web) = 595 X 842 pixels
- 300 dpi (print) = 2480 X 3508 pixels (This is "A4" as I know it, i.e. "210mm X 297mm @ 300 dpi")
- 600 dpi (print) = 4960 X 7016 pixels
And so forth. FWIW document formats like A4 are described by their print dimensions (millimeters), which is a whole different thing than screen images (pixels) so that's why you don't see anyone using pixels to describe A4. :yes