widthToPixel(len: String);
len. Length expressed in some measurement untis.
The widthToPixel method converts length values to pixels.
This method returns a Number type value if executed successfully, otherwise it returns null.
As a parameter, set a value specifying any measurement units, such as 1mm.
To execute the example, add a link to PP.js scenario file to HTML page. Convert length value from millimeters to pixels:
//Determine length value var length = "5mm"; console.log("Length in millimeters: " + length); // Transform the specified value into pixels length = PP.widthToPixel(length); console.log("Length in pixels: " + Math.round(length));
After executing the example the browser console displays length value in millimeters and in pixels:
Length in millimeters: 5mm
Length in pixels: 19
See also: