Submitty icon indicating copy to clipboard operation
Submitty copied to clipboard

PDF Annotate is broken

Open bidwej opened this issue 6 years ago • 2 comments

Describe the bug PDF Annotate crashes when running the Submitty sample code. @submitty/pdf-annotate.js says to submit bug reports to the main Submitty/Submitty repository. The "pdf-annotate.js" project is no longer maintained for reference.

I'd like to contribute to fixing the problem if anyone has any pointers. The render call on line 4150 of "pdf-annotate.js" looks correct. I think the issue may have something to do with the canvas context.

Expected behavior A PDF should render with annotations from "MyStoreAdapter".

To Reproduce Steps to reproduce the behavior:

Run the following code

import pdfjsLib from 'pdfjs-dist/build/pdf';
import PDFJSAnnotate from 'pdfjs-annotate';
import MyStoreAdapter from './myStoreAdapter';
 
const { UI } = PDFJSAnnotate;
const VIEWER = document.getElementById('viewer');
const RENDER_OPTIONS = {
  documentId: 'MyPDF.pdf',
  pdfDocument: null,
  scale: 1,
  rotate: 0
};
 
pdfjsLib.workerSrc = 'pdf.worker.js';
PDFJSAnnotate.setStoreAdapter(MyStoreAdapter);
 
pdfjsLib.getDocument(RENDER_OPTIONS.documentId).promise.then((pdf) => {
  RENDER_OPTIONS.pdfDocument = pdf;
  VIEWER.appendChild(UI.createPage(1));
  UI.renderPage(1, RENDER_OPTIONS);
});
  1. See error "PDFPageProxy.getViewport is called with obsolete arguments"

Configuration

  • OS: Windows
  • Browser Chrome

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

bidwej avatar Jun 29 '20 16:06 bidwej

Sorry for the (very) late response on this. It got shuffled onto my backlog of things, and then drowned by other stuff. The "onboarding" experience of getting started with the library outside of Submitty has not been a priority for us as we've not had anyone else try to use it (and we somewhat didn't expect anyone would). I still have on my backlog of rewriting the README which I will try to commit later on this week when I'm back at my primary machine, and not get distracted with other build tasks related to the project (like setting up a demo GH pages for it).

The README example should be updated as the ./myStoreAdapter does not exist out of the box and is perhaps confusing to someone who might (accurately) believe it does. A more accurate call for an example would be:

PDFJSAnnotate.setStoreAdapter(new PDFJSAnnotate.LocalStoreAdapter());

which will then set the adapter to use the LocalStoreAdapter which just stores the annotations into localStorage memory.

The web/index.js file gives a good example of using the library (and is also the basis for when you do npm start in the repo): https://github.com/Submitty/pdf-annotate.js/blob/master/web/index.js

MasterOdin avatar Jul 28 '20 04:07 MasterOdin

Updated the readme in Submitty/pdf-annotate.js@41d082cfd94e554d80febceae48b898c86377a0a. Please feel free to reopen this issue if using the LocalStoreAdapter does not work.

MasterOdin avatar Jul 31 '20 20:07 MasterOdin