Skip to content

Configure Measurement Properties

To set measurement scale and precision, you can utilize the class CPDFMeasureInfo within the ComPDFKit.Measure.

This example shows how to configuring measurement properties:

C#
MeasureSetting measureSetting = new MeasureSetting();

// Set the measurement scale in the PDF file to 1.0 inch.
measureSetting.RulerBase = 1.0;
measureSetting.RulerBaseUnit = CPDFMeasure.CPDF_IN;

// Set the translation of 1.0 inch in the PDF to correspond to 10.0 feet in the actual object.
measureSetting.RulerTranslate = 10.0;
measureSetting.RulerTranslateUnit = CPDFMeasure.CPDF_FT;

// Set the precision to 0.01.
measureSetting.Precision = CPDFMeasure.PRECISION_VALUE_TWO;

// (For enclosed graphics with measurable area) Set to display the area in the annotation appearance.
measureSetting.IsShowArea = true;

// (For enclosed graphics with measurable perimeter) Set to display the perimeter in the annotation appearance.
measureSetting.IsShowLength = true;

Supported Measurement Units

You can set the units for the measurement ruler on the PDF file and the size units for the actual object using MeasureSetting.RulerBaseUnit and MeasureSetting.RulerTranslateUnit. The supported units and corresponding parameter values are listed in the table below:

UnitConstantValue
PointCPDFMeasure.CPDF_PTpt
InchCPDFMeasure.CPDF_INin
MillimeterCPDFMeasure.CPDF_MMmm
CentimeterCPDFMeasure.CPDF_CMcm
MeterCPDFMeasure.CPDF_Mm
KilometerCPDFMeasure.CPDFO_KMkm
FootCPDFMeasure.CPDF_FTft
YardCPDFMeasure.CPDF_YDyd
MileCPDFMeasure.CPDF_MImi