Which product are you using?
PDF.js Express Plus – paid for license
PDF.js Express Version
|UI version|‘8.4.1’|
|Core version|‘8.4.0’|
Detailed description of issue
Hi there! I am looking for some assistance in being able to get my annotations working. I have not been able to find examples/documentation with a full working version.
Key functionalities I need:
- Load document in the document viewer (working)
- load/see existing annotations (XDF)
- create/add annotations
- save annotations
- send annotations XDF to third party API
- repeat
Currently I am able to get the ribbon toolbar working via the ui.instance.enableElements([“”]) method, but nothing happens when I click any of the icons (free text tool, highlight, etc). I get an error
Expected behaviour
Would love to be able to utilize the annotation tools
Does your issue happen with every document, or just one?
All documents/haven’t been able to get it to work yet
Link to document
{Provide a link to the document in question if possible}
Code snippet
WebViewer(
{
path: `${process.env.PUBLIC_URL}/pdfjsexpress`,
initialDoc: "",
disableFlattenedAnnotations: true,
},
viewer.current,
)
.then((instance) => {
const utils = new ExpressUtils();
const { docViewer, Core, annotManager } = instance;
instance.UI.loadDocument(
"https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf",
,
{ filename: "myfile.pdf" },
);
instance.UI.setTheme("dark");
instance.UI.enableElements([
"ribbons",
"toolsHeader",
"leftPanel",
"leftPanelButton",
]);
docViewer.addEventListener("documentLoaded", async () => {
console.log("document loaded");
});
})
I have tried this snippet found in docs already (only to test something that would show up – didn’t work):
// const annotManager = docViewer.getAnnotationManager();
// const rectangle = new Annotations.RectangleAnnotation();
// rectangle.PageNumber = 2;
// rectangle.X = 100;
// rectangle.Y = 100;
// rectangle.Width = 250;
// rectangle.Height = 250;
// rectangle.Author = annotManager.getCurrentUser();
// annotManager.addAnnotation(rectangle);
// docViewer.displayLastPage();