How do I a scale and a distance (measure) tool with PDFTron SDK?

403 views
Skip to first unread message

Support

unread,
Apr 9, 2013, 12:37:10 PM4/9/13
to pdfne...@googlegroups.com

Q:

Is it possible to add a scale and a distance tool with your PDF sdk?

In pdf document for construction you have to scale the pdf or calibrate it so you can pull a distance or measurement between 2 points. Many times a pdf is scaled such as 1\4 inch = 1 foot. To pull a correct dimension between two points you have to calibrate the measurement tool to the scale. Let me know if you need a better explanation.
 
We are looking primarily at .NET but we may be also interested in mobile and other platfroms.

----------
A:
 
At the moment, we do not support measure annotation out of the box, however it is possible to implement this support as a 'custom annotation'.

With on how to get started with a custom tool in .NET and WPF please see attached sample code. The sample shows how to draw a rectangle on top of PDF page. It covers most of the issues with catching events, calibrating between screen and page space, and so on. It should give you a good starting point for creating your own tool. Instead of drawing a rectangle, you could change the code to draw a line. You could also modify it a bit to give the user a widget to drag around. Once you've selected the 2 points, you will likely want to give the user some form of dialog box to type in the distance between these two points.
 
Once this is done, you can convert the two points to page space, like so:

double downX = _DownPoint.X;
double downY = _DownPoint.Y;
_PDFView.ConvScreenPtToPagePt(ref downX, ref downY, _PageNumber);

This would give you two points that you could use on any computer or surface, without needing to re-calibrate between screen sizes or anything like that.

Once you have this measurement, it could even be stored in the PDF annotation's SDF dictionary . 

For example, you can or create measure dictionary through optional 'Measure' entry (Section 12.9 'Measurement Properties' in ISO32000 PDF Reference - http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf) in line annotation dictionary (annot.GetSDFObj().FindObj("Measure") etc. For more info on for to use SDF/Cos API please see SDF sample project (http://www.pdftron.com/pdfnet/samplecode.html#SDF).
 
 
 
 
 
 
 
 
CalibrationTool.cs
Reply all
Reply to author
Forward
0 new messages