如何在反应中使用pdf js express从pdf中删除高亮注释
How to delete highlight annotation from pdf with pdf js express in react
我正在使用pdf js express在pdf中绘制高亮注释。但是当我无法从 pdf 中删除注释时。我正在使用此代码创建突出显示:
const { Annotations, annotManager } = instance;
citations.forEach((citation) => {
if (citation.quads && isNumber(citation.page) && !isNaN(parseInt(citation.id))) {
const citationAuthor = citation.created_by && citation.created_by.user
? `${citation.created_by.user.first_name} ${citation.created_by.user.last_name}`.trim()
: author;
const highlight = new Annotations.TextHighlightAnnotation();
highlight.Author = citationAuthor;
highlight.Quads = citation.quads;
highlight.PageNumber = citation.page;
highlight.Id = citation.id.toString();
highlight.Locked = true;
highlight.Subject = 'Citation';
annotManager.addAnnotation(highlight, true);
annotManager.drawAnnotations(highlight.PageNumber);
}
});
我没有找到删除突出显示注释的任何方法,这基本上会从 pdf 中删除突出显示
您必须先获取 Annotations 对象,然后使用 deleteAnnotation API 删除高亮注释。尝试以下:
highlight = annotManager.getAnnotationById( yourCitationId);
annotManager.deleteAnnotation(highlight)
我正在使用pdf js express在pdf中绘制高亮注释。但是当我无法从 pdf 中删除注释时。我正在使用此代码创建突出显示:
const { Annotations, annotManager } = instance;
citations.forEach((citation) => {
if (citation.quads && isNumber(citation.page) && !isNaN(parseInt(citation.id))) {
const citationAuthor = citation.created_by && citation.created_by.user
? `${citation.created_by.user.first_name} ${citation.created_by.user.last_name}`.trim()
: author;
const highlight = new Annotations.TextHighlightAnnotation();
highlight.Author = citationAuthor;
highlight.Quads = citation.quads;
highlight.PageNumber = citation.page;
highlight.Id = citation.id.toString();
highlight.Locked = true;
highlight.Subject = 'Citation';
annotManager.addAnnotation(highlight, true);
annotManager.drawAnnotations(highlight.PageNumber);
}
});
我没有找到删除突出显示注释的任何方法,这基本上会从 pdf 中删除突出显示
您必须先获取 Annotations 对象,然后使用 deleteAnnotation API 删除高亮注释。尝试以下:
highlight = annotManager.getAnnotationById( yourCitationId);
annotManager.deleteAnnotation(highlight)