How to determine the Page View rectangle?

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

How to determine the Page View rectangle?

Post by DSSavant »

I need to create a “Quick Zoom Operation” but do not quite know which routines to call. The operation would basically have the following algorithm:

1. From within the Viewer’s event handler, if the event is for a Left Mouse button Down and the Hand Tool is active and the Control key is down then:
> a. Prevent the Viewer from acting on the mouse click.
> > i. "Notifications.Mouse.Skip"
> b. Figure out where the mouse click was at.
> > i. "Notifications.Mouse.x", etc.
> c. Zoom in 2X using the mouse click point as the center of my “zoom window”.
> > i. Get zoom - “Documents[1234].Pages.Zoom”, “get”
> > ii. Zoom = Zoom * 2
> > iii. Set zoom - “Documents[1234].Pages.Zoom”, “set”, …
> > iv. HOW TO DO THIS - Now set the “view window” to be centered on the click point:
> > > 1. Get the rectangle of the view window.
> > > 2. Do funky math and move the view window to be centered on mouse click.
> d. When the Mouse Up event is sent, reset the “view window” to where it was prior to zooming in.

So, how do I tell the Viewer where to “focus” its zoom window at or how do I tell it to move its view window or page view or ??? to a given location? If I were using the Acrobat SDK, I would use the term Page View.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to determine the Page View rectangle?

Post by Vasyl - PDF-XChange »

In the new build you will be able to do it. For this:

1. To determine pages view screen size (this is new feature, will be in new build):

Code: Select all

ctrl.GetDocumentProperty(docId, "Pages.Width", out w, 0);
ctrl.GetDocumentProperty(docId, "Pages.Height", out h, 0);
2. To determine page index/coord under mouse pointer (pseudocode):

Code: Select all

eventhandler OnEvent(type, name)
{
  if ((type == PXCVA_OnNamedNotify) AND (name == "Notifications.Mouse"))
  {
      int docId;
      ctrl.GetProperty("Notifications.Mouse.Document", out docId, 0);
      int pgIdx;
      ctrl.GetProperty("Notifications.Mouse.Page", out pgIdx, 0);
      if (pg >= 0)
      {
          int x,y;
          ctrl.GetProperty("Notifications.Mouse.x", out x, 0);
          ctrl.GetProperty("Notifications.Mouse.y", out y, 0);
          int scrPt[2];
          scrPt[0] = x;
          scrPt[1] = y;
          float pgPt[2];
          ctrl.DoDocumentVerb(docId, "Pages[" + ToString(pgIdx) + "]", "TranslateScreenPoint", scrPt, out pgPt, 0);
          ....
      }
   }
}

3. To move page point to the specified screen point (feature will be in the next build):

Code: Select all

IPDFXCargs args;
// create empty IPDFXCargs object (see our SDK help):
...
// fill 'args' object 
args.Add(pgPtX);
args.Add(pgPtY);
args.Add(scrPtX);
args.Add(scrPtY);
ctrl.DoDocumentVerb(docId, "Pages[" + ToString(pgIdx) + "]", "MovePointToScreenPoint", args, NULL, 0);
For your Quick Zoom feature you may use: TranslateScreenPoint + MovePointToScreenPoint + Pages.Zoom property.
The new build upcoming.

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to determine the Page View rectangle?

Post by DSSavant »

Great! Thank you. Any idea when the next build will be available?
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7371
Joined: Wed Mar 25, 2009 10:37 pm

Re: How to determine the Page View rectangle?

Post by Paul - PDF-XChange »

hi DSSavant

2.5 should be any day now...
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to determine the Page View rectangle?

Post by DSSavant »

Thanks Paul/Support, just ping this thread whenever it is.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7371
Joined: Wed Mar 25, 2009 10:37 pm

Re: How to determine the Page View rectangle?

Post by Paul - PDF-XChange »

Hi DSSavant,

we were trying to get the beta out today but it will be tomorrow. This beta will be available from the regular Viewer download page: https://www.pdf-xchange.com/product ... nge-viewer. There is already a place holder for it. The notice currently delivered will be replaced with the beta installer when it's uploaded.

I'll confirm here when it's up.
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to determine the Page View rectangle?

Post by DSSavant »

Just wanted to say THANKS! I got my feature implemented using your new stuff. Again, thanks, I appreciate it.

The only other thing I could ask for (in the far future) is a way to determine the center point of the PDF Viewing rectangle -- the point in screen coordinates that represents the center of the PDF Viewing rectangle (would not include the thumbnails or other panes). I could see that being very handy for positioning areas of document to the user.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7371
Joined: Wed Mar 25, 2009 10:37 pm

Re: How to determine the Page View rectangle?

Post by Paul - PDF-XChange »

Thanks DSSavant,

I`m very pleased to hear you have implemented the new features. As to determining the centre of the Viewing area - I think Vasyl will have to comment... ;-)
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to determine the Page View rectangle?

Post by Vasyl - PDF-XChange »

Hi, DSSavant.
The only other thing I could ask for (in the far future) is a way to determine the center point of the PDF Viewing rectangle -- the point in screen coordinates that represents the center of the PDF Viewing rectangle (would not include the thumbnails or other panes). I could see that being very handy for positioning areas of document to the user.
If I understand you correctly - it's possible already:

Code: Select all

ctrl.GetDocumentProperty(docId, "Pages.Width", out w, 0);
ctrl.GetDocumentProperty(docId, "Pages.Height", out h, 0);
// the center point of pages view, x,y coordinates are relative to top/left corner of pages view window:
int centerX = w/2;
int centerY = h/2;
HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to determine the Page View rectangle?

Post by DSSavant »

ctrl.GetDocumentProperty(docId, "Pages.Width", out w, 0);
ctrl.GetDocumentProperty(docId, "Pages.Height", out h, 0);
Correct, this will give me the width and height respectively of the PDF Document Page itself in points (1/72 of an inch). That is good. What I'm looking for is the center of the Viewing area on the screen. The Viewing area will not change in size with regard to the PDF Document Page that is being displayed within it. When I size the Viewer and make it bigger, the viewing area will be bigger. When I maximize it, the viewing area will be large. If I collapse the thumbnail, comments, etc. panes, it will be as big as it's gonna get. That is the view I would like to get the center of. I looked at Pages.MediaBox and CropBox but both return 0. I would suspect that what I'm after would fit logically as something like:

ctrl.GetDocumentProperty(docId, "View.Panes[??_PDF_VIEW_PANE_??].Width", out w, 0);
ctrl.GetDocumentProperty(docId, "View.Panes[??_PDF_VIEW_PANE_??].Height", out w, 0);

The output would be in pixels. And then I would use TranslateScreenPoint to center a point on the document to the center of the viewing pane. This would allow me to take the point under a mouse click and move it to the center of the view area.

Hopefully that made sense.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How to determine the Page View rectangle?

Post by Vasyl - PDF-XChange »

Hi, DSSavant.
Correct, this will give me the width and height respectively of the PDF Document Page itself in points (1/72 of an inch)
No, the code:

Code: Select all

ctrl.GetDocumentProperty(docId, "Pages.Width", out w, 0);
ctrl.GetDocumentProperty(docId, "Pages.Height", out h, 0);
-- gives you the width/height in pixels of the Viewing area on the screen. The size of the Viewing area isn't related with current pdf-page, current zoom, current pages layout. It equals to screen-size of pages view window only (the thumbnails pane, bookmarks pane, scrollbars, etc. are not included).
I looked at Pages.MediaBox and CropBox but both return 0.
The "Pages.MediaBox" name is incorrect, you should specify the zero-based index of page: Pages[0].MediaBox ... Pages[PagesCount-1].MediaBox.

HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: How to determine the Page View rectangle?

Post by DSSavant »

You are so very wise and correct!

Subtle difference in syntax. My bad.

That's what I was looking for, thanks.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7371
Joined: Wed Mar 25, 2009 10:37 pm

Re: How to determine the Page View rectangle?

Post by Paul - PDF-XChange »

:)
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com