PDF.js Express Version
8.0.1
Detailed description of issue
Previously in version 7.2.1, I write some code [code provided in code snippet section] to get the annotation id, quad, text, and page no but in version 8.0.1 I have not found annotations[0][‘Ku’], annotations[0].Ob, annotations[0].E_, annotations[0].JF this attributes from annotations object.
Expected behavior
When I highlight some text then it will highlight the text but now got this error, " Unhandled Rejection (TypeError): Cannot read properties of undefined (reading ‘toString’)"
Does your issue happen with every document, or just one?
It happens for every document.
Link to document
- https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0240011&type=printable
- https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0207335&type=printable
Code snippet
annotManager.on('annotationChanged', (annotations, action, { imported }) => {
const citations = this.props.citations.filter(x => x.id == annotations[0]['Ku']);
annotManager.exportAnnotCommand().then((xfdfString) => {
var xfdfJson = JSON.parse(convert.xml2json(xfdfString, { compact: true, spaces: 4 }).toString());
if (xfdfJson.xfdf.add['highlight'] !== undefined && xfdfJson.xfdf.add['text'] === undefined && annotations[0]['Subject'] === "Highlight" && citations.length === 0 && action === 'add') {
const highlight = annotManager.getAnnotationById(annotations[0]['Ku'].toString());
this.props.onTextSelectionChanged({
quads: annotations[0].Ob,
text: annotations[0].E_,
page: annotations[0].JF,
});
}
})
});