Setting initial page

Which product are you using?
PDF.js Express Viewer

PDF.js Express Version

Detailed description of issue
Is there a way to set initial page number when opening a document?

Expected behaviour
I want to save last viewed page number and next time when opening the same document, it should start from that page.

Does your issue happen with every document, or just one?

Link to document
Below is the code of useEffect() hook in one of my Next.js components:

useEffect(() => {
      import("@pdftron/pdfjs-express-viewer").then(() => {
            path: "/webviewer/lib",
            licenseKey: process.env.NEXT_PUBLIC_PDFJS_KEY,
        ).then((inst: any) => {
          instance.current = inst;

          // Set the document
          const blob = new Blob([bookBuffer], {
            type: "application/octet-stream",

          // Set the language

          // Disable elements
          const elements = [
          if (contentIsScanned) {

          // Get page number
          const { documentViewer } = inst.Core;
          documentViewer.addEventListener('pageNumberUpdated', (pageNumber: number) => {
            currentPage = pageNumber;
            console.log("PAGE NUMBER", pageNumber)
  }, [bookId]);

Hi there,

Thank you for reaching out to pdf.js express forums,

One way could be to save the page number (i.e. database) as you have in the above code, then use that page number to set the current document page on documentLoad:

Best regards,
Kevin Kim

1 Like

Wow, it worked.
I’ve been calling setCurrentPage() on the inst instead of documentViewer.
Anyways, I appreciate your help, thanks a lot!