使用 Python 管理 PDF 中的注释

现代 Python 库,用于使用我们的 API 管理 PDF 注释。

如何使用 Python for .NET 库管理注释

为了在 PDF 文件中添加文本注释,我们将使用 Aspose.PDF for .NET API,这是一款功能丰富、功能强大且易于使用的适用于 python-net 平台的文档处理 API。打开 NuGet 软件包管理器,搜索 aspose.pdf 然后安装。您也可以从软件包管理器控制台使用以下命令。

Python Package Manager Console

pip install aspose-pdf

通过 Python 在 PDF 文档中创建注释


你需要 Aspose.PDF for Python 才能在你的环境中试用代码。

1.在 “文档” 类的实例中加载 PDF。 1.创建要添加到 PDF 的注释。 1.将注释添加到 Page 对象的 “注释” 集合中。 1.保存 PDF 文件。

PDF 文本注释-Python。

Example: Python

    def text_annotation_add(self, infile, outfile):

        path_infile = self.dataDir + infile
        path_outfile = self.dataDir + outfile

        pdfDocument = Document(path_infile)

        textAnnotation = TextAnnotation(pdfDocument.Pages[1], Rectangle(299.988, 713.664, 308.708, 720.769))
        textAnnotation.Title = "Aspose User"
        textAnnotation.Subject = "Inserted text 1"
        textAnnotation.Flags = AnnotationFlags.Print
        textAnnotation.Color = Color.Blue

        pdfDocument.Pages[1].Annotations.Add(textAnnotation)
        pdfDocument.Save(path_outfile)