Convert mm to pixel

Hi.
I need a method to convert milimeter to pixel.
I'm using the iText to generate pdf'docs. When I set the document size I need a com.lowagie.text.Rectangle Object.
The Rectangle takes float width, float height as arguments and I guess it is pixel.

I only have the correct  messures for the file I need to create in mm.
Any Idea how to do this?
kristian_grAsked:
Who is Participating?
 
CPColinSenior Java ArchitectCommented:
iText uses PostScript points as its measurement. Google reports these values for conversion:

1 PostScript point = 0.352777778 millimeters
1 millimeter = 2.83464567 PostScript points
1 inch = 72 PostScript points
1 inch = 25.4 millimeters

You should be able to get some conversions out of that.
0
 
objectsCommented:
depends on the dpi you want to display it as

mm = 254 * pixels / dpi;
pixels = (mm * dpi) / 254
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
The approx conversion is

1pxl = 0.3125 mm
0
 
zzynxSoftware engineerCommented:
I think the correct formula is:

 pixels = (mm * dpi) / 25.4


Let me explain a little bit.

1 inch = 25.4 mm

If we assume a resolution of e.g. 300 dpi (that's 300 dots or pixels per inch)
then 100 mm (being approx. 4 inches) is 300*4 = 1200 pixels

The formula gives:
100 * 300 / 25.4 = 1181 pixels
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.