Add Footer to PDF using Python

Add Footer to PDF File using Python for .NET.

Add Footers to PDF Document Using Python

In order to add footers into PDF file, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation API for python-net platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Console

pip install aspose-pdf

Steps to add Footer to PDF using Python


You need Aspose.PDF for Python via .NET to try the code in your environment.

  1. Open a PDF document using Document object.
  2. Create a Stamp and define its properties.
  3. Add the Stamp to Page using AddStamp method.
  4. Save the PDF file.

Add Image in Footer of PDF File - Python

This sample code shows how to add image in footer of PDF

import aspose.pdf as apdf

from os import path

path_infile = path.join(self.data_dir, infile)
path_outfile = path.join(self.data_dir, outfile)

document = apdf.Document(path_infile)

footerText = apdf.Text.TextFragment("This is a footer")
footer = apdf.HeaderFooter()
footer.Paragraphs.Add(footerText)
marginInfo = apdf.MarginInfo()
marginInfo.Left = 50
marginInfo.Top = 20

for page in document.pages:
    page.footer = footer

document.save(path_outfile )