Another question related to custom annotations. I am currently using setCustomDrawHandler to display a a number within a circle at the bottom-right corner of the annotation. The method above is achieved through redrawing the canvas but that does not actually modify the xfdf file, correct? I am using annotManager.exportAnnotations() to grab the latest xfdf file, but I do not see a correlation or a pattern with the numbers. My concern is that when we “merge” the pdf file and xfdf file, I will not see the numbered annotations on the downloadable pdf.
Will the numbered annotations be present in that file? If not, is there a way to grab the xfdf file with those custom annotations? Is there a way to directly modify the xfdf file to include numbers?
If so, do you see a way to include these numbered annotations only when exporting the pdf?
Thanks,
Ryan
Expected behaviour
{Provide a screenshot or description of the expected behaviour}
Does your issue happen with every document, or just one?
{Answer here}
Link to document
{Provide a link to the document in question if possible}
Just to clarify, when I setCustomData I will see the number inside a circle at the bottom right hand corner of the sticky annotation? See below screenshot.
If this is the case, do you see a way to include these numbered annotations only when exporting the pdf and not when the user is viewing the document through the viewer?
Custom data only works inside the PDF.js Express viewer. Since what you are doing is outside of the PDF spec, other PDF viewers will not be able to render it (since they do not know your rendering logic).
Unfortunately this is just the way PDFs work and there is not a great way to accomodate your use case in PDF.js Express.
That being said, our sister product PDFTron WebViewercan accomodate this use case as it is able to flatten custom annotations into a document. If you really need to support this use case, upgrading to WebViewer is the only option. Another plus side of WebViewer is that it can do all these operations client side - no rest API needed. WebViewer has the exact same API as PDF.js Express, so if you wanted to try it out, your current code will work as-is. We have a guide on migrating here.
Ya that is one option, you could convert your annotations to stamps which essentially saves them as a bitmap. You lose a lot of flexibility this way when importing though which is why I did not suggest it.
We do have that CustomAnnotation class that is mentioned in that guide, but unfortunately you would have to reimplement all the existing annotations drawing logic if you take that approach.