PDFtron 便签标签

问题描述 投票:0回答:1

有没有办法在便签顶部添加类似于下图的标签?除了使用便签添加和分组文本之外。

if (action == 'add') {
  for (const annot of annots) {
    if (annot instanceof instance.Core.Annotations.StickyAnnotation) {
      const label = new Annotations.FreeTextAnnotation(Annotations.FreeTextAnnotation.Intent.FreeText, {
        X: annot.X,
        Y: annot.Y - 15,
        TextColor: new Annotations.Color(0, 0, 0),
        StrokeColor: new Annotations.Color(255, 255, 255, 0),
        Width: annot.Width,
        Height: 15,
      });

      label.setContents(annot.Subject);
      instance.Core.annotationManager.addAnnotation(label);
      instance.Core.annotationManager.redrawAnnotation(label);
      instance.Core.annotationManager.groupAnnotations(annot, [annot, label]);
    }
  }
}
javascript pdf annotations pdftron stickynote
1个回答
0
投票

默认情况下,PDF 规范不支持此功能,但是您正在使用 Apryse WebViewer,因此有多种方法可以实现类似的行为。

第1步: 创建您的笔记注释

第2步: 将标签创建为 FreeTextAnnotation:https://docs.apryse.com/documentation/web/guides/annotation/types/FreeTextAnnotation/

第3步: 通过以下方式将这些注释分组在一起:https://docs.apryse.com/documentation/web/guides/annotation/annotationmanager/grouping#reading-grouped-annotations

由于这是一种不受支持的行为,并且是自定义行为,因此不能保证在其他 PDF 查看器中正常工作,但是如果您仅在 WebViewer 中查看 PDF,则应该没问题。

© www.soinside.com 2019 - 2024. All rights reserved.