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:
| Unit | Constant | Value |
|---|---|---|
| Point | CPDFMeasure.CPDF_PT | pt |
| Inch | CPDFMeasure.CPDF_IN | in |
| Millimeter | CPDFMeasure.CPDF_MM | mm |
| Centimeter | CPDFMeasure.CPDF_CM | cm |
| Meter | CPDFMeasure.CPDF_M | m |
| Kilometer | CPDFMeasure.CPDFO_KM | km |
| Foot | CPDFMeasure.CPDF_FT | ft |
| Yard | CPDFMeasure.CPDF_YD | yd |
| Mile | CPDFMeasure.CPDF_MI | mi |