PP.widthToPixel

Syntax

widthToPixel(len: String);

Parameters

len. Length expressed in some measurement untis.

Description

The widthToPixel method converts length values to pixels.

Comments

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.

Example

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:

PP