【问题标题】:How to delete highlight annotation from pdf with pdf js express in react如何在反应中使用pdf js express从pdf中删除突出显示注释
【发布时间】:2021-02-14 18:41:42
【问题描述】:

我正在使用 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 中删除高亮

【问题讨论】:

标签: reactjs pdf pdf.js pdf.js.express


【解决方案1】:

您必须先获取 Annotations 对象,然后使用 deleteAnnotation API 删除高亮注释。尝试以下:

highlight = annotManager.getAnnotationById( yourCitationId);
annotManager.deleteAnnotation(highlight)

【讨论】:

    猜你喜欢
    • 2019-12-25
    • 2016-05-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 2014-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多