Skip to content

Configure Measurement Properties

To set measurement scale and precision on a global level, you can utilize the static class MeasureSetting within the ComPDFKitViewer.PdfViewer.

This example shows how to configuring measurement properties:

C#
public void SetMeasureSettings()
{
    // 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.RulerTranslateUnit = 0.01;

    // (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