Gerencie anotações em PDF com Python

Biblioteca moderna Python para gerenciar anotações em PDF usando nossas APIs.

Como gerenciar anotações usando a biblioteca Python for .NET

Para adicionar Anotação de texto no arquivo PDF, usaremos a API Aspose.PDF for .NET, que é uma API de manipulação de documentos rica em recursos, poderosa e fácil de usar para a plataforma python-net. Abra o gerenciador de pacotes NuGet, pesquise Aspose.pdf e instale. Você também pode usar o seguinte comando no Console do Gerenciador de Pacotes.

Python Package Manager Console

pip install aspose-pdf

Crie anotações em um documento PDF via Python


Você precisa do Aspose.PDF for Python para testar o código em seu ambiente.

  1. Carregue PDF em uma instância da classe Document.
  2. Crie uma anotação que você deseja adicionar ao PDF.
  3. Adicione a anotação à coleção Annotations do objeto Page.
  4. Salve o arquivo PDF.

Anotação de texto em 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)