I already know how to add an annotation at a given mouse coordinate. What I'm having issues with is finding the center point of the viewable area for the active page.
When I run the following routine on a one page PDF:
Code: Select all
object top;
object bottom;
object left;
object right;
// Media Box
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].MediaBox.Top", "get", null, out top);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].MediaBox.Bottom", "get", null, out bottom);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].MediaBox.Left", "get", null, out left);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].MediaBox.Right", "get", null, out right);
Debug.WriteLine(string.Format("Media Box - Top: {0}, Bottom: {1}, Left: {2}, Right: {3}.", top, bottom, left, right));
// Crop Box
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].CropBox.Top", "get", null, out top);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].CropBox.Bottom", "get", null, out bottom);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].CropBox.Left", "get", null, out left);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].CropBox.Right", "get", null, out right);
Debug.WriteLine(string.Format("Crop Box - Top: {0}, Bottom: {1}, Left: {2}, Right: {3}.", top, bottom, left, right));
// Pane Width and Height...
object pageHeight;
object pageWidth;
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].Height", "get", null, out pageHeight);
Viewer.DoDocumentVerb(ActiveDocumentId, "Pages[0].Width", "get", null, out pageWidth);
Debug.WriteLine(string.Format("Page Width: {0}, Height: {1}.", pageWidth, pageHeight));
// Viewer Pane Width and Height...
object viewPaneWidth;
object viewPaneHeight;
Viewer.GetDocumentProperty(ActiveDocumentId, "Pages.Width", out viewPaneWidth, 0);
Viewer.GetDocumentProperty(ActiveDocumentId, "Pages.Height", out viewPaneHeight, 0);
Debug.WriteLine(string.Format("View Pane Width: {0}, View Pane Height: {1}.", viewPaneWidth, viewPaneHeight));
I get the same output for the given document no matter if I'm zoomed in 1000% or zoomed out to 6%. I, incorrectly, assumed that CropBox would give me the coordinates for the visible part of the active page within the viewer and that MediaBox would give me the full area required by the active page (really, its width and height).Media Box - Top: 792, Bottom: 0, Left: 0, Right: 612.
Crop Box - Top: 792, Bottom: 0, Left: 0, Right: 612.
Page Width: 612, Height: 792.
View Pane Width: 397, View Pane Height: 244.
Any clarification as to what these methods provide and what methods I actually need to use would be appreciated.