[Tool] Sychronize view of documents (pan, zoom, etc)  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

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

Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

[Tool] Sychronize view of documents (pan, zoom, etc)  SOLVED

Post by Mathew »

There's a built-in tool in the works, but until then: This tool allows you to select two (or more) documents and set their view/zoom/page/etc to synchronize between them. This is a rewrite of a tool originally written by @benep at viewtopic.php?t=39797 and then updated by me at viewtopic.php?t=42070

Usage
The tool will add a "Sync Views" button to the Add-ons toolbar, and also a menu item to the View ribbon (or the View menu):
image.png
With at least two documents open, start the tool. It will give a dialog:
image(1).png
Documents
  • Select the documents you want to view. The menu adds the number of pages in the document at the end.
    The Show button brings the selected document to the front.
    If the dialog has more than 2 documents listed, there will be a [-] button to remove this document from the sync.
    Starting page can be adjusted if the option to sync page numbers is not active.
[+] Add documents to the sync
  • The tool can sync more than two documents, if desired. If there are more than 2 documents open, select the [+] to add another document picker.
    image(2).png
Settings
  • Pick which aspects you want to synchronize between the documents.
View
  • If you want the tool to set up split views, pick vertical or horizontal split views
    If page sizes differ between the documents, the "Scale view" option will move the pages relative to the page borders, rather than the same absolute distance
Prompts
  • If you selected "Do not show this again" in any of the pop-up dialogs, you can reset them here.
To Cancel the sync, either select the tool again, or close one of the documents. If you select the tool again, it will give a dialog with three options:
  • image(3).png
    Stop Sync just cancels the sync (and returns the documents to one tab group if the vertical/horizontal split was used).
    Edit Sync re-opens the Sync Views dialog box to change which documents, the pages, the sync options, etc.
    Cancel returns to they synchronized documents.
    There's also a checkbox to hide this pop-up dialog and go to the option you select (except cancel) without asking next time.

Installation
Unzip and save in JavaScripts folder, then restart PDF XChange. You may need to make the folder. Either in
C:\Users\[USERNAME]\AppData\Roaming\Tracker Software\PDFXEditor\3.0\Javascripts
OR
C:\Program Files\Tracker Software\PDF Editor\Javascripts
scrollsync v1.4.zip

If you are using PDF-XChange before build 393 you'll also need xutils downloadable from here:
viewtopic.php?t=44731

Translations
This tool can be translated using 1ang.js. Save the translation file into the Javascripts folder also, and the tool will pick up and use the translation for your currently selected language in PDF-XChange. I've attached the template translation file below and the tool at viewtopic.php?p=186101#p186101 will help editing the file to add translations. I added a machine translation (Google translate) to simplified Chinese "CHS" and Ukrainian "UKR" (I have no idea how accurate it is!)
Russian translation added thanks to @sklart viewtopic.php?p=196680#p196680
translationData.scrollSync.json.zip
image(4).png


tl;dr
I re-wrote the tool to address issues with security settings, as well as rounding problems with page coordinates. It also uses the updated app.setInterval() method that allows functions to be assigned directly. This eliminated the need for a global variable to hold the interval, and let me enclose all its data inside the function. I added options to allow splitting horizontally or vertically, and which aspects of the view should be synchronized.

Limitations/known bugs
  • If using the ribbon (horizontal) continuous views, and documents have differing page sizes, there will be some weird results: While scrolling in large pages, the page number in other synchronized document(s) will jump around wildly. Small pages may get stuck off-screen. This, I think, is because the script is trying to set the scroll position past the edge of a smaller page -- I've spent way too much time trying to figure it out and so far haven't succeeded. Workaround is: don't use ribbon continuous views with this tool if the document pages differ from one another.
If you see bugs, or can add translations, please post!
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Thu Oct 23, 2025 1:41 am, edited 16 times in total.
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

I updated to v1.1 above, fixing some bugs and adding the ability to sync more than two documents.

Changes since v1.0
  • Sync more than 2 docs;
  • Don't disable the page number input for doc1;
  • add alert if sync cancelled by too few docs (uses menu cMarked to run the check),
  • misc dialog cleanup,
  • save page number delta instead of looking at change (for different sized pages, but ribbon view will still be weird)
This is the superceded v1.0 version:
scrollsync v1.0.zip
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Mon Mar 24, 2025 6:54 pm, edited 1 time in total.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11888
Joined: Wed Jan 03, 2018 6:52 pm

[Tool] Sychronize view of documents (pan, zoom, etc)

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

v1.2 uploaded above. Tool seems to be working OK for me now, at last!

Changes since v1.1
  • fix bug introduced in v1.1 with page changing backwards;
  • try to handle scrolling in ribbon/continuous view when page sizes don't match (still doesn't work well in ribbon view when page sizes differ);
  • add option to scale scroll by page size so that two different pages move proportionally
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2608
Joined: Mon Jan 15, 2018 9:01 am

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Dimitar - PDF-XChange »

Great Job, Mathew. :-)

Thank you.
Mo_Yous
User
Posts: 2
Joined: Sun Apr 13, 2025 8:37 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mo_Yous »

Hello Mathew,

Thanks for the great work!

For some reason the tool v1.0 and v1.2 are not working for me, but older versions like v0.6.1 is working!
I'm on build number 395
image.png
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19919
Joined: Mon Jan 12, 2009 8:07 am

[Tool] Sychronize view of documents (pan, zoom, etc)

Post by Stefan - PDF-XChange »

:)
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

Mo_Yous wrote: Sun Apr 13, 2025 8:42 pm For some reason the tool v1.0 and v1.2 are not working for me, but older versions like v0.6.1 is working!
I'm on build number 395
Hi @Mo_Yous,
Could you help me figure this out: What does v1.2 do? Do you get any error message in the JavaScript console?
Thanks,
Mathew.
Mo_Yous
User
Posts: 2
Joined: Sun Apr 13, 2025 8:37 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mo_Yous »

Mathew wrote: Mon Apr 14, 2025 2:47 pm
Hi @Mo_Yous,
Could you help me figure this out: What does v1.2 do? Do you get any error message in the JavaScript console?
Thanks,
Mathew.
Hi @Mathew,

I get this error
"Mozilla JavaScript Engine is initialized (ES2017+)
App:Init:214: TypeError: docID is not a function"

Changing the "findIndex" to "indexOf" in line 214 solved the error. :D

Regards,
Mohamed
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

Mo_Yous wrote: Mon Apr 14, 2025 7:26 pm Hi @Mathew,

I get this error
"Mozilla JavaScript Engine is initialized (ES2017+)
App:Init:214: TypeError: docID is not a function"

Changing the "findIndex" to "indexOf" in line 214 solved the error. :D

Regards,
Mohamed
Thank you Mohamed! I'll upload a revised version 1.3. Much appreciated.
Mathew.
scrollsync v1.3.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11888
Joined: Wed Jan 03, 2018 6:52 pm

[Tool] Sychronize view of documents (pan, zoom, etc)

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
ben_b
User
Posts: 1
Joined: Tue Aug 12, 2025 2:44 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by ben_b »

Novice question here... how does one install this feature?
Mathew wrote: Mon Apr 14, 2025 9:54 pm
Mo_Yous wrote: Mon Apr 14, 2025 7:26 pm Hi @Mathew,

I get this error
"Mozilla JavaScript Engine is initialized (ES2017+)
App:Init:214: TypeError: docID is not a function"

Changing the "findIndex" to "indexOf" in line 214 solved the error. :D

Regards,
Mohamed
Thank you Mohamed! I'll upload a revised version 1.3. Much appreciated.
Mathew.
scrollsync v1.3.zip
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7407
Joined: Wed Mar 25, 2009 10:37 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Paul - PDF-XChange »

Hi, ben_b

Mathew posted it originally here: viewtopic.php?p=178290#p178290
Unzip and save in JavaScripts folder. You may need to make the folder. Either in
C:\Users\[USERNAME]\AppData\Roaming\Tracker Software\PDFXEditor\3.0\Javascripts
OR
C:\Program Files\Tracker Software\PDF Editor\Javascripts

OR: copy, paste the script below and save as a text file scrollSync.js in the JavaScripts folder.
:D
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

I made a post in the sticky topic -- not sure why I didn't think to do before -- with detailed instructions:

viewtopic.php?p=196006#p196006
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2608
Joined: Mon Jan 15, 2018 9:01 am

[Tool] Sychronize view of documents (pan, zoom, etc)

Post by Dimitar - PDF-XChange »

:)
sklart
User
Posts: 2
Joined: Thu Nov 28, 2024 9:27 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by sklart »

translationData.scrollSync.json.zip
Added translation into Russian
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11888
Joined: Wed Jan 03, 2018 6:52 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Daniel - PDF-XChange »

Hello, sklart

Thank you very much!

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
BS2
User
Posts: 7
Joined: Thu Sep 04, 2025 7:26 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by BS2 »

Thank you for this excellent tool! It has been great for my work.

I just wanted to report a possible bug when syncing two views. I tried to fix it by editing the javascript on my computer but I wasn't able to figure out the issue. This can be recreated by opening two of the same document (say of two drawings with slightly different notes) and then zooming in on one. The zoom on the other will match the first but the panning will be different. It seems like this could be a simple change by updating the panning when a zoom event is detected but I wasn't able to do it. If the document is then panned, it triggers an update and it is back in sync.
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

BS2 wrote: Tue Oct 21, 2025 4:19 pm This can be recreated by opening two of the same document (say of two drawings with slightly different notes) and then zooming in on one. The zoom on the other will match the first but the panning will be different. It seems like this could be a simple change by updating the panning when a zoom event is detected but I wasn't able to do it. If the document is then panned, it triggers an update and it is back in sync.
Thanks for the note: I see the problem and will update the tool -- I'll post it here when I've got it done.
BS2
User
Posts: 7
Joined: Thu Sep 04, 2025 7:26 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by BS2 »

Thank you! This tool really is excellent! Do you have a tip jar for your efforts? I'd love to contribute.
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

This update (I think) fixes the problem noted by @BS2 here viewtopic.php?p=198035#p198035

Changes in v1.4
  • fix pan location when zoom changed
scrollsync v1.4.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2608
Joined: Mon Jan 15, 2018 9:01 am

[Tool] Sychronize view of documents (pan, zoom, etc)

Post by Dimitar - PDF-XChange »

:)
BS2
User
Posts: 7
Joined: Thu Sep 04, 2025 7:26 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by BS2 »

Thanks again Matthew! That fixed the zoom issue. :D

I also wanted to mention two other items:

Is there a reason for the two buttons in the add-on bar? Not a big deal - just curious.

And also, I noticed a small amount of drift when panning in certain situations. Sometimes there would be no drift and sometimes there would be some depending on how fast the pan was or how much it moved in the last 30 millisecond syncInterval. I played around with the code and changed the minDelta function to always return 0.001 for pageViewY, pageViewX, and everything else. This seemed to fix the small amounts of drift during some pans. I don't know what consequences this has but it seems to work great on my end. It looks like previously it was using a calculation based on the pageViewZoom.

See below for my test code changes:

// for deciding if the changes are big enough to warrant updating
const isChanged = (delta, d, property) => {
const minDelta = ('pageViewY' === property || 'pageViewX' === property) ? 1 / d.viewState.pageViewZoom 0.001 : 0.001;
return Math.abs(delta) > minDelta;
};

Although, this code would be equivalent to just setting minDelta to 0.001. There may also be a better way to calculate a minimum delta.

Anyways, this may cause other issues. I just thought I would share because it seemed to work for me.

Thanks again for your excellent work!
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

BS2 wrote: Thu Oct 23, 2025 2:00 pm Thanks again Matthew! That fixed the zoom issue. :D

I also wanted to mention two other items:

Is there a reason for the two buttons in the add-on bar? Not a big deal - just curious.

And also, I noticed a small amount of drift when panning in certain situations. Sometimes there would be no drift and sometimes there would be some depending on how fast the pan was or how much it moved in the last 30 millisecond syncInterval.
The two buttons: The code is only adding one button to the add-on bar, BUT I suspect it's related to how PXCE is remembering changes to the toolbars. You can eliminate the second one by going to Customize Toolbars… (in the top right corner)
image.png
Then delete one of the duplicate buttons out of the add-on toolbar from the right click menu:
image(1).png

The isChanged() function takes into account the zoom level. I can't duplicate your issue - do you have a sample pdf you can post? I was finding that at greater zoom levels, it needed to be a smaller number, but if it's working fine for you with a fixed number: great. I think the number that should be changed is the numerator for that fraction -- ie if it's a smaller number it will be more sensitive to changes in position and also more likely to drift, so my expectation is that it's more likely to drift with your change(?) Can you try this - let me know if it works:

Code: Select all

// for deciding if the changes are big enough to warrant updating
const isChanged = (delta, d, property) => {
    const minDelta = ('pageViewY' === property || 'pageViewX' === property) ? 1.5 / d.viewState.pageViewZoom : 0.001;
    return Math.abs(delta) > minDelta;
};
You do not have the required permissions to view the files attached to this post.
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2608
Joined: Mon Jan 15, 2018 9:01 am

[Tool] Sychronize view of documents (pan, zoom, etc)

Post by Dimitar - PDF-XChange »

:)
BS2
User
Posts: 7
Joined: Thu Sep 04, 2025 7:26 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by BS2 »

Thanks for the reply Matthew! Sorry for the delay - I have been busy and have been doing some testing.

Thanks for the suggestion on the two buttons - I figured I could just delete one but I wasn't sure if there was some weird reason in the code that two showed up. I checked that I didn't have two scripts loaded and when I deleted the file, both buttons disappeared. Your fix worked and it wasn't a big deal to start with.

I think the value needs to be smaller overall to make sure the the changes are updated more frequently. The weird part is that at 66.7%, there seems to be movement much more frequently no matter what I try to adjust. I tried your suggestion and found that it made it worse. I then tried 0.1 in the numerator and it worked better but with that strange issue at 66.7%. It is working well enough as is. I'll keep playing some more and see if I can find out any more.

Also, the way that I am doing the testing is by opening two copies of the same exact PDF. I am syncing these together and have them displayed in two tabs but not side by side. I am then ctrl + tabbing between them and scrolling/panning around. It becomes very obvious when they are off. With these recent changes (and especially with smaller minDelta values) they are locked together very well for the most part.

Thanks again for the help!
Mathew
User
Posts: 709
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Sychronize view of documents (pan, zoom, etc)

Post by Mathew »

BS2 wrote: Tue Oct 28, 2025 10:43 pm I think the value needs to be smaller overall to make sure the the changes are updated more frequently. The weird part is that at 66.7%, there seems to be movement much more frequently no matter what I try to adjust. I tried your suggestion and found that it made it worse. I then tried 0.1 in the numerator and it worked better but with that strange issue at 66.7%. It is working well enough as is. I'll keep playing some more and see if I can find out any more.

I may not be understanding the issue: at certain percentages is the view constantly moving slowly in one direction?

tl;dr:
The reason I added this function in the first place is that there's some rounding issues at certain percentages (66.7% was one of them where it would happen), so that the reported position pageViewY or pageViewX would be slightly different than the value that was applied, so the script would be constantly updating and the view would 'drift' in one direction. I added this function as a tolerance, so difference between the value applied and the reported value less than this tolerance wouldn't trigger the script to update the position. I found that I couldn't use a fixed value, because at different zoom levels, the tolerance needed to be different.