Now I am trying to make a application using WPF/c#.
In this application, I looked at prototyping this XChange viewer SDK
but do not know if I can get a scroll event notification from the control,
or if I can find the current scroll position of each page on the screen.
I am looking for an event such as ScrollPositionChanged (or document position changed) that would allow me to then interrogate the current HScollPos and VScrollPos on the instance raising the event and set these same values on the other layer control of WPF.
Is there any way to get this information from XChange Viewer SDK ?
regards,
yohan.
How to get the scroll position...
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: How to get the scroll position...
Hi, Yohan.
Sorry, no way for this in current version. Please wait for version V3.
Best
regards.
Sorry, no way for this in current version. Please wait for version V3.
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 23
- Joined: Mon Sep 09, 2013 8:38 am
Re: How to get the scroll position...
Looking for the same event as topic starter - scroll event notification.
Is it available in the current version of SDK?
Is it available in the current version of SDK?
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: How to get the scroll position...
Hi, vzgherea and yohan.
Now exists one new undocumented feature to synchronize scroll positions of two(or more) opened documents.
Methods:
Document::GetVPos()
Document::SetVPos()
Event:
Type=PXCVA_OnNamedNotify, Name="Notifications.ScrollChanged"
Look to attached C# example that displays it.
Also you may use next trick. To get current view position:
To restore the previously saved view position:
HTH
Now exists one new undocumented feature to synchronize scroll positions of two(or more) opened documents.
Methods:
Document::GetVPos()
Document::SetVPos()
Event:
Type=PXCVA_OnNamedNotify, Name="Notifications.ScrollChanged"
Look to attached C# example that displays it.
Also you may use next trick. To get current view position:
Code: Select all
struct ScrollPos
{
int pageIndex;
double x;
double y;
}
ScroolPos spos;
object dataIn;
object dataOut;
GetDocumentProperty(docID, "Pages.Current", out dataOut, PXVA_Sync);
spos.pageIndex = dataOut;
// [0,0] screen point to pdf-coord. system of current page:
DoDocumentVerb(docID, "Pages[" + spos.pageIndex + "]", "TranslateScreenPoint", dataIn(0, 0), out dataOut, PXVA_Sync);
spos.x = dataOut[0];
spos.y = dataOut[1];
Code: Select all
DoDocumentVerb(docID, "Pages[" + spos.pageIndex + "]", "MovePointToScreenPoint", dataIn(spos.x, spos.y, 0, 0), null, PXVA_Sync);
You do not have the required permissions to view the files attached to this post.
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 23
- Joined: Mon Sep 09, 2013 8:38 am
Re: How to get the scroll position...
Many thanks for your post, it is very helpful!
But I can't still solve my issue. I am implementing document compare functionality. Each document has only one page and is loaded in it's own control. It is necessary to synchronize scrolling in both controls and it has to be done proportionally, e.g. 50% of scrolling in first control has to set scrolling to 50% in the second control, even in case size of pages is different or orientation of pages is different.
Could you give me a hint how this could be achieved?
But I can't still solve my issue. I am implementing document compare functionality. Each document has only one page and is loaded in it's own control. It is necessary to synchronize scrolling in both controls and it has to be done proportionally, e.g. 50% of scrolling in first control has to set scrolling to 50% in the second control, even in case size of pages is different or orientation of pages is different.
Could you give me a hint how this could be achieved?
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: How to get the scroll position...
You may try to use one undocumented way:It is necessary to synchronize scrolling in both controls and it has to be done proportionally, e.g. 50% of scrolling in first control has to set scrolling to 50% in the second control, even in case size of pages is different or orientation of pages is different.
Code: Select all
m_bSkipScrollEvent = false;
axCoPDFXCview1.SetProperty("Notifications.ScrollChanged.Enabled", 1, 0);
axCoPDFXCview2.SetProperty("Notifications.ScrollChanged.Enabled", 1, 0);
...
youreventhandker axCoPDFXCview1_OnEvent(type, name, dataIn)
{
if (!m_bSkipScrollEvent && (type == PXCV_OnNamedNotify) AND (name == "Notifications.ScrollChanged"))
{
m_bSkipScrollEvent = true;
LONG pageIndex = dataIn[0];
double dxPage = dataIn[3];
double dyPage = dataIn[4];
double pw, ph;
axCoPDFXCview1.GetDocumentProperty(0, "Pages[ + pageIndex + "].Width", out pw, PXCVA_NoUI | PXCVA_Sync);
axCoPDFXCview1.GetDocumentProperty(0, "Pages[ + pageIndex + "].Height", out ph, PXCVA_NoUI | PXCVA_Sync);
double xz = dxPage / pw;
double yz = dyPage / ph;
double pw, ph;
axCoPDFXCview2.GetDocumentProperty(0, "Pages[ + pageIndex + "].Width", out pw, PXCVA_NoUI | PXCVA_Sync);
axCoPDFXCview2.GetDocumentProperty(0, "Pages[ + pageIndex + "].Height", out ph, PXCVA_NoUI | PXCVA_Sync);
dxPage = pw * xz;
dyPage = ph * yz;
dataIn[3] = dxPage;
dataIn[4] = dyPage;
axCoPDFXCview2.DoDocumentVerb(0, "", "SetVPos", dataIn, null, PXCVA_NoUI | PXCVA_Sync);
m_bSkipScrollEvent = false;
}
}
...
youreventhandker axCoPDFXCview2_OnEvent(type, name, dataIn)
{
if (!m_bSkipScrollEvent && (type == PXCV_OnNamedNotify) AND (name == "Notifications.ScrollChanged"))
{
m_bSkipScrollEvent = true;
LONG pageIndex = dataIn[0];
double dxPage = dataIn[3];
double dyPage = dataIn[4];
double pw, ph;
axCoPDFXCview2.GetDocumentProperty(0, "Pages[ + pageIndex + "].Width", out pw, PXCVA_NoUI | PXCVA_Sync);
axCoPDFXCview2.GetDocumentProperty(0, "Pages[ + pageIndex + "].Height", out ph, PXCVA_NoUI | PXCVA_Sync);
double xz = dxPage / pw;
double yz = dyPage / ph;
double pw, ph;
axCoPDFXCview1.GetDocumentProperty(0, "Pages[ + pageIndex + "].Width", out pw, PXCVA_NoUI | PXCVA_Sync);
axCoPDFXCview1.GetDocumentProperty(0, "Pages[ + pageIndex + "].Height", out ph, PXCVA_NoUI | PXCVA_Sync);
dxPage = pw * xz;
dyPage = ph * yz;
dataIn[3] = dxPage;
dataIn[4] = dyPage;
axCoPDFXCview1.DoDocumentVerb(0, "", "SetVPos", dataIn, null, PXCVA_NoUI | PXCVA_Sync);
m_bSkipScrollEvent = false;
}
}
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.