Contentserv PHP API

CSUnitConvUtils
in package

This utility class is the entry point to unit conversion functionality.

Tags
since
13.0

Table of Contents

UNIT_CM  = 'cm'
UNIT_IN  = 'in'
UNIT_MM  = 'mm'
Measure units
UNIT_PT  = 'pt'
UNIT_PX  = 'px'
UNIT_REFBASE  = self::UNIT_MM
Basic measuring reference unit
convertCmToMm()  : float
Convert centimeters into millimeters.
convertInToMm()  : float
Convert inches into millimeters.
convertMmToCm()  : float
Convert millimeters into centimeters.
convertMmToIn()  : float
Convert millimeters into inches.
convertMmToPt()  : float
Convert millimeters into points (at a fixed resolution of 72 ppi).
convertMmToPx()  : int
Convert millimeters into pixels at a specific resolution.
convertPdfPtToScreenMm()  : array<string|int, mixed>
Converts a point in the PDF (which is fixed at a resolution of 72 ppi) into a screen point (in millimeters).
convertPtToMm()  : float
Convert points into millimeters (at a fixed resolution of 72 ppi).
convertPxToMm()  : float
Convert pixels into millimeters at a specific resolution.
convertScreenMmToPdfPt()  : array<string|int, mixed>
Converts a point on the screen (in millimeters) into PDF points (which is fixed at a resolution of 72 ppi).
getUnitName()  : string
Return the full measurement unit name for a given abbreviation.
getUnits()  : array<string|int, mixed>
Retrieve the list of measurement units which are handled by this utility class.

Constants

UNIT_REFBASE

Basic measuring reference unit

public mixed UNIT_REFBASE = self::UNIT_MM
Tags

Methods

convertCmToMm()

Convert centimeters into millimeters.

public static convertCmToMm(float $fCentimeters) : float
Parameters
$fCentimeters : float

The value to convert (in centimeters).

Tags
access

public

Return values
float

The converted value (in millimeters).

convertInToMm()

Convert inches into millimeters.

public static convertInToMm(float $fInches) : float
Parameters
$fInches : float

The value to convert (in inches).

Tags
access

public

Return values
float

The converted value (in millimeters).

convertMmToCm()

Convert millimeters into centimeters.

public static convertMmToCm(float $fMillimeters) : float
Parameters
$fMillimeters : float

The value to convert (in millimeters).

Tags
access

public

Return values
float

The converted value (in centimeters).

convertMmToIn()

Convert millimeters into inches.

public static convertMmToIn(float $fMillimeters) : float
Parameters
$fMillimeters : float

The value to convert (in millimeters).

Tags
access

public

Return values
float

The converted value (in inches).

convertMmToPt()

Convert millimeters into points (at a fixed resolution of 72 ppi).

public static convertMmToPt(float $fMillimeters) : float
Parameters
$fMillimeters : float

The value to convert (in millimeters).

Tags
access

public

Return values
float

The converted value (in points).

convertMmToPx()

Convert millimeters into pixels at a specific resolution.

public static convertMmToPx(float $fMillimeters[, float $fResolution = 96.0 ]) : int
Parameters
$fMillimeters : float

The value to convert (in millimeters).

$fResolution : float = 96.0

The resolution at which to convert (in pixels per inch).

Tags
access

public

Return values
int

The converted value (in pixels), using common rounding.

convertPdfPtToScreenMm()

Converts a point in the PDF (which is fixed at a resolution of 72 ppi) into a screen point (in millimeters).

public static convertPdfPtToScreenMm(array<string|int, mixed> $amPdfPoint, array<string|int, mixed> $amMediaSize) : array<string|int, mixed>

This implies a change of the underlying coordinate system from PAPER_PDF to SCREEN and is only possible if an absolute media size of the PDF is specified.

Parameters
$amPdfPoint : array<string|int, mixed>

A point structure, containing the point to relocate (specified in PDF points).

$amMediaSize : array<string|int, mixed>

A size structure, defining the dimensions of the target PDF (specified in millimeters).

Tags
access

public

Return values
array<string|int, mixed>

A point structure, containing the point coordinates as seen from the screen (in millimeters).

convertPtToMm()

Convert points into millimeters (at a fixed resolution of 72 ppi).

public static convertPtToMm(float $fPoints) : float
Parameters
$fPoints : float

The value to convert (in points).

Tags
access

public

Return values
float

The converted value (in millimeters).

convertPxToMm()

Convert pixels into millimeters at a specific resolution.

public static convertPxToMm(int $iPixels[, float $fResolution = 96.0 ]) : float
Parameters
$iPixels : int

The value to convert (in pixels).

$fResolution : float = 96.0

The resolution at which to convert (in pixels per inch).

Tags
access

public

Return values
float

The converted value (in millimeters).

convertScreenMmToPdfPt()

Converts a point on the screen (in millimeters) into PDF points (which is fixed at a resolution of 72 ppi).

public static convertScreenMmToPdfPt(array<string|int, mixed> $amScreenPoint, array<string|int, mixed> $amMediaSize) : array<string|int, mixed>

This implies a change of the underlying coordinate system from SCREEN to PAPER_PDF and is only possible if an absolute media size of the PDF is specified.

Parameters
$amScreenPoint : array<string|int, mixed>

A point structure, containing the screen point to relocate (specified in millimeters).

$amMediaSize : array<string|int, mixed>

A size structure, defining the dimensions of the target PDF (specified in millimeters).

Tags
access

public

Return values
array<string|int, mixed>

A point structure, containing the point coordinates as seen from the PDF view port (in points).

getUnitName()

Return the full measurement unit name for a given abbreviation.

public static getUnitName(string $sUnitAbbreviation) : string
Parameters
$sUnitAbbreviation : string

The abbreviation for which the full name should be determined.

Tags
access

public

Return values
string

The full name/translation key of the given unit, if it can be handled by this class. If the abbreviation is unknown, an empty string is returned.

getUnits()

Retrieve the list of measurement units which are handled by this utility class.

public static getUnits() : array<string|int, mixed>
Tags
access

public

Return values
array<string|int, mixed>

An associative array, where the keys indicate the unit constants/abbreviations and the values contain the appropriate unit names.


        

Search results