Tutorials

Build a PDF Measuring Tool for Your Windows App

By ComPDFKit | Mon. 10 Mar. 2025
Measurement

Build a PDF Measuring Tool for Your Windows App

 

Although AutoCAD provides precise measurement tools, PDF measuring tools are also necessary for architectural designs. PDF design drawings are often easier to view in construction sites and review processes while ensuring that the drawings remain unaltered.

 

In construction, review, approval, collaboration, and archiving, PDF measurement functionality remains essential. Follow this guide to build a PDF Measuring Tool.



What PDF Measuring Tools Does ComPDF Offer?

 

The ComPDF measurement feature allows you to measure PDF drawings precisely. Experience measurement PDF online demo and see the details.

 

  1. Measure distance, angle, area, perimeter, line, rectangle, circle, polygon, multiline, arc.

  2. Configure measurement properties like scale and precision. 

  3. Adjust Existing Measurement Annotations.

  4. Set the appearance of the line and text to mark up the measurement results. 

 

PDF Measurement tools

 

 

Step 1: Requirements - ComPDF Measurement for Windows

 

Before you start, ensure that you meet the following requirements:

 

 

 

Step 2: Create a New Windows App Project

 

Create a new Windows application project in Visual Studio by clicking Create a new project.


 Create a new Windows project

 

Click WPF App (.NET Framework) —> Next.


Click WPF App (.NET Framework

 

Configure your project: Set your project name and choose the location to store your program. The project name is called "ComPDFKit Demo" in this example. This sample project uses .NET Framework 4.6.1 as the programming framework.

 

Configure your project

 

Click the Create button. Then, a new project will be created.



Step 3: Add ComPDF Measurement to Your Windows Project

 

You can add ComPDF measurement PDF SDK to your project by Nuget repository.

 

  • Open your project’s solution, and in the Solution Explorer, right-click on References and click on the menu item Manage NuGet Packages…. This will open the NuGet Package Manager for your solution.

 

open the NuGet Package Manager for your solution

 

  • Search for ComPDFKit.NetFramework and you’ll find the package on nuget.org.

  • On the right side, in the panel describing the package, click on the Install button to install the package.


install the package

 

  • Once that is complete, you’ll see a reference to the package in the Solution Explorer under References.


reference to the package

 

  • Add the Demo -> Measurement module of ComPDF to your project.



Step 4: Apply License for Your PDF Measuring Tool

 

Before using the measurement feature, you must get and apply for your ComPDFKit license. This ensures that all functionalities are unlocked and available for use.

 

 

Windows   Web   Android   iOS   Mac   Server   React Native   Flutter   Electron
30-day Free

 

You can find the license in an XML file which our sales send to you after you contact us. Open the XML file, and determine the license type based on the <type> field. If <type>online</type> is present, it indicates an online license. If <type>offline</type> is present, it indicates an offline license.

 

Online License:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<license version="1">
    <platform>windows</platform>
    <starttime>xxxxxxxx</starttime>
    <endtime>xxxxxxxx</endtime>
    <type>online</type>
    <key>LICENSE_KEY</key>
</license>

 

Offline License:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<license version="1">
    <platform>windows</platform>
    <starttime>xxxxxxxx</starttime>
    <endtime>xxxxxxxx</endtime>
    <key>LICENSE_KEY</key>
</license>

 

Copy the value located at the LICENSE_KEY position within the <key>LICENSE_KEY</key> field. This is your license key.



Step 5: Configure Measurement Properties in C#

 

Before using the measurement feature, configure the scale, units, and precision settings. Here is a code example with the following configuration. You can adjust these settings based on your specific project needs.

 

  • Measurement Scale: 1.0 inch

  • Real-World Length Equivalent: 1.0 inch in the PDF equals 10.0 feet in the actual object.

  • Precision Setting: 0.01

 

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;

 

Additionally, ComPDF supports multiple measurement units, which can be adjusted accordingly.

 

If you have any questions when integrating ComPDF for Windows, please contact our support team or publish your questions on GitHub.

 

 

Step 6: Start to Measure Your PDF Drawings

 

Once everything is set up, your program will enable your users to measure PDF drawings with our Windows SDK. There is a video showing how to use the measurement functionality.

 

Windows   Web   Android   iOS   Mac   Server   React Native   Flutter   Electron
30-day Free

 

What’s More!

 

After integrating ComPDF measurement, you can also add other powerful features, such as:

 

  • Viewing

  • Annotations

  • Signatures

  • Document Comparison

 

By combining these features, you can create a complete workflow for PDF drawing measuring, reviewing, and approving within your application.