Q: I am drawing a rectangle on top of your PdfView class, which works
fine. I store the page number, the start, and end point in screen
What is the recommended way to get the rectangle to position properly
after PdfView is scrolled? Do I use your transformation matrix
somehow, do I translate the screen coordinates into page coordinates
then back into screen coordinates, or do I use the scroll values from
PdfView to adjust the rectangle on the screen?
I looked at your sample code for the PdfView and see that you multiply
a matrix, but that changed my rectangle (even though it did scroll the
flipped and stretched rectangle, and I see where you translate screen
coordinates to page coordinates, but that isn't what I'm trying to do.
What do you do in my case?
A: Instead of storing points in screen coordinates, you can convert
them to page (or canvas) coordinate system. The advantage of PDF page
(or canvas) coordinate system is that it is device independent. So if
the page is scrolled, rotated, zoomed, etc your data will display
exactly where it should. To paint the geometry and custom markup (in
your OnPaint method) you would need to convert back from page (or
canvas) coordinate system to screen coordinates. All of this is
illustrated in PDFView C# or VB sample project (http://www.pdftron.com/
net/samplecode.html#PDFView - you may want to look at code that draw a
rectangle for custom link creation tool or custom markup tool).
The main difference between page and canvas coordinate systems is that
canvas surrounds all pages within a PDFView page layout (you can look
at it as a single page that encircles all pages in the document
layout). As a result the conversion functions that work with canvas do
not need a page number to convert to and from screen coordinates.
Similar to PDF page coordinate system this coordinate system is device
independent and is using points as units. In PDFView class there are
utility methods (pdfview.Conv...) that can be used to convert points
back and forth between canvas, screen, and page coordinates.