Skip to content

Measure Perimeter and Area

The perimeter and area measurement tool can be used to measure the perimeter and area of a polygonal region selected by the user.

After configuring the measurement properties, you can set up the CPDFViewer to create a perimeter and area measurement tool mode through the following steps:

  1. Create a PolygonMeasureArgs object, which can be used to set properties for the perimeter and area measurement tool.
  2. Set the mouse mode to annotation creation mode.
  3. Pass the PolygonMeasureArgs object for the perimeter and area measurement tool.

Here is an example code for creating the perimeter and area measurement tool:

C#
private AnnotHandlerEventArgs CreatePolygonal()
{
    // Create a PolygonMeasureArgs object to set properties for the perimeter and area measurement tool.
    PolygonMeasureArgs polygonMeasureArgs = new PolygonMeasureArgs();
    polygonMeasureArgs.LineColor = Colors.Red;
    polygonMeasureArgs.LineWidth = 2;
    polygonMeasureArgs.Transparency = 1;
    polygonMeasureArgs.FontColor = Colors.Red;
    polygonMeasureArgs.FillColor = Colors.Transparent;
    polygonMeasureArgs.FontName = "Arial";
    polygonMeasureArgs.FontSize = 14;

    // Set the mouse mode to annotation creation mode.
    pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);

    // Pass the PolygonMeasureArgs object for the perimeter and area measurement tool.
    pdfViewer?.SetToolParam(polygonMeasureArgs);
    return polygonMeasureArgs;
}