litePDF C++ interface  1.3.1

Since litePDF the functions which used millimeters as their measure units can use also inches, or fractions of the millimeters and inches (see TLitePDFUnit). The reason for the fraction is to not use architectural dependent types in the API, where the double type is. The unit value is rounded down to unsigned integers in the API. The default unit is set to millimeters (LitePDFUnit_mm) for backward compatibility.

Call TLitePDF::GetUnit to determine which unit is currently used. To change the unit to be used call TLitePDF::SetUnit. For example, to create a page of size 8.5 inches x 11.0 inches, set the unit to LitePDFUnit_10th_inch and then call the TLitePDF::AddPage with the width 85 and height 110 (10-times larger, because the current unit is 1/10th of an inch).

To make the calculations easier, the TLitePDF::MMToUnit and TLitePDF::InchToUnit functions were added, which recalculate the passed-in value in millimeters, respectively inches, to the currently set unit, while the rounding to integer values is left for the caller. There are also the inverse functions, TLitePDF::UnitToMM and TLitePDF::UnitToInch.

All functions use the unit set for the current context, except of the TLitePDF::DrawResource, which has an explicit argument for the unit value. That's for simplicity, to not need to change the units before the function is called and then set it back after the call. Similar helper functions TLitePDF::MMToUnitEx and TLitePDF::InchToUnitEx are available.

The rounding down from double to unsigned int can suffer of the double precision error, thus it's a good idea to add a little fraction to the returned values from the conversion helper functions before the rounding. The unitvalues example adds 0.1 to the returned value from the TLitePDF::MMToUnit to ensure the value will be rounded "up" in case the double precision error makes the value slightly smaller than it is supposed to be (considered double precision error is around 1e-9).