Regarding replicating any user PDFJS express

Hello @Logan, @zzhang

Hope you are doing well.
I wanted to replicate a user’s webviewer to another user’s webviewer.
For instance, if 1st user moves to third page of pdf,
automatically 2nd user’s webviewer should also move to third page
without second user interering.

I have tried this my , taking 1st user webviewer zoom details and pagenumber
and calling custom Node js API to update it in a file kept on server at every 500ms. And 2nd user will take details from that file via custom API and reflect it in his webviewer.
But this seems pretty expensive operation calling API every 500ms and
it also depends on 1st user internet performance.

Can you suggest any solution which will implement above feature
without depending on any user’s internet performance either
using firebase or something else.
Your suggestion could help me a lot.

Abhishek Maurya

Hi there,

This is a bit out of scope of PDF.js Express, but we can offer a suggestion.

The best way I can think of to accomplish this is to use WebSockets. The most popular library for using WebSockets is ws. WebSockets are real-time connections between server and client. So what you can do is listen for changes on the client (page changed, zoom changed) etc, and send these events to your WebSocket server. Your WebSocket server would then broadcast these events to any other connected user.

Another solution would be to use Firebases realtime capabilities. You could create a new firebase document for each PDF, and in the document save the state of the user (zoom, page). Any other user could subscribe to changes to that firebase document.

I hope this helps a bit!