Footer in PDF

Adding images and text to PDF footer section can be useful in various scenarios, such as adding branding or legal information to documents. In many industries, it’s a common requirement to add a company logo or disclaimer at the bottom of each page of a document. In other cases, there may be a need to add page numbers or other metadata to help organize or identify the document. Regardless of the specific use case, the ability to add images and text to the footer section of a PDF document is an important feature for many businesses and organizations. In this article, we will explore how to add images and text to the footer section of a PDF document using Python Cloud SDK.

Another term used for the footer is called running foot. It is greatly used in the publishing industry and is called as such because, it contains a shortened version of the article or other pieces of information about it.

Python Cloud SDK

Aspose.PDF Cloud SDK for Python provides a set of powerful features for working with PDF documents, including the ability to add image and text to the footer section of a PDF document. This SDK offers a simple and intuitive interface that makes it easy to perform various PDF-related tasks programmatically. Using this SDK, you can quickly and easily add custom text or images to the footer of any PDF document, providing a professional and customized look to your documents.

The SDK is available for download over PIP and GitHub repository. However, you may simply execute the following command on the terminal/command prompt to install the latest version of SDK on the system.

pip install asposepdfcloud

The next important step is to obtain client credentials from Cloud dashboard. If you have GitHub or Google account, simply Sign Up or, click on the Create a new Account button and provide the required information.

Client credentials

Image 1:- Client Credentials on Aspose.Cloud Dashboard.

Please follow the steps given below to add text footer in PDF document using Python code snippet.

  • The first step is to create an instance of ApiClient class which requires Client ID Client Secret as arguments.
  • Secondly, create an instance of PdfApi class which requires ApiClient object as input argument.
  • Thirdly, create an object of TextFooter where we have set the horizontal alignment as Center, Opacity as 0.7, rotate angle as 356 and have specified bottom margin as 5.
  • In order to set text formating for TextFooter, create an object of TextState where we define foreground color, font size, font name etc.
  • Now we need to set values for two optional parameters defining start and end page of PDF document to place Text Footer.
  • Finally, call the post_document_text_footer(..) method to add Text Footer to PDF document and save resultant file to Cloud storage.
Text Footer preview

Image 2:- Preview of TextFooter added to PDF.

Please visit the following link to download the input marketing.pdf and the resultant marketing-TextFooter.pdf.

The API also provides the capabilities to add an Image footer to a PDF file. Please follow the instructions given below to accomplish this requirement.

  • The first step is to create an instance of ApiClient class which requires Client ID Client Secret as arguments.
  • Secondly, create an instance of PdfApi class which requires ApiClient object as input argument.
  • Thirdly, create an object of ImageFooter where we have set the horizontal alignment as Center, Opacity as 0.7, rotate angle as 10, image file name, margin details and other properties are specified.
  • Since we only need to add the Footer to first page of document, so we have set values for start_page_number and end_page_number optional parameters.
  • Finally, call the post_document_image_footer(..) method to add Text Footer to PDF document and save resultant file to Cloud storage.
Image Footer in PDF

Image 3:- Preview of Image Footer in PDF.

The resultant file generated by the above example can be downloaded from marketing-ImageFooter.pdf.

The usage of cURL commands and Aspose.PDF Cloud to add text and Image in PDF footer offers several benefits. First, it eliminates the need for manual editing of PDF documents, which can be time-consuming and prone to errors. Second, it allows for easy customization of the header text, with the ability to change the font, size, color, and position of the text. Third, it enables users to add text to multiple PDF documents simultaneously, saving time and increasing efficiency. Finally, this approach provides a secure and reliable method for adding text to the PDF header, with all data being transmitted over a secure connection and processed on secure servers.

Now, as a pre-requisite, generate a JSON Web Token (JWT) by executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=88d1cda8-b12c-4a80-b1ad-c85ac483c5c5&client_secret=406b404b2df649611e508bbcfcd2a77f" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have generated the JWT token, we need to execute the following command to add TextFooter to PDF file.

curl -X POST "https://api.aspose.cloud/v3.0/pdf/marketing.pdf/footer/text?startPageNumber=2&endPageNumber=3" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"Background\": true,  \"HorizontalAlignment\": \"Center\",  \"Opacity\": 0.7,  \"Rotate\": \"None\",  \"RotateAngle\": 5,  \"XIndent\": 100,  \"YIndent\": 100,  \"Zoom\": 0.8,  \"Value\": \"Aspose.PDF Cloud SDK for Python\",  \"TextState\": {    \"FontSize\": 15,    \"Font\": \"Arial\",    \"ForegroundColor\": {      \"A\": 0,      \"R\": 66,      \"G\": 111,      \"B\": 245    },    \"BackgroundColor\": {      \"A\": 10,      \"R\": 179,      \"G\": 245,      \"B\": 66    },    \"FontStyle\": \"Regular\"  },  \"BottomMargin\": 3,  \"LeftMargin\": 3,  \"RightMargin\": 3}"

Please execute the following command to add the image header to the PDF file using the cURL command.

curl -X POST "https://api.aspose.cloud/v3.0/pdf/marketing.pdf/footer/image?startPageNumber=1&endPageNumber=1" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"Background\": false,  \"HorizontalAlignment\": \"Left\",  \"Opacity\": 0.7,  \"Rotate\": \"None\",  \"RotateAngle\": 10,  \"XIndent\": 10,  \"YIndent\": 10,  \"Zoom\": 0.7,  \"FileName\": \"Koala.jpg\",  \"Width\": 100,  \"Height\": 100,  \"BottomMargin\": 2,  \"LeftMargin\": 1,  \"RightMargin\": 10}"

Conclusion

In conclusion, adding image and text to the footer section of a PDF document can be a useful feature for various purposes, including branding, legal compliance, and document organization. Aspose.PDF Cloud SDK for Python provides a convenient and powerful way to implement this feature in your Python application. On the other hand, using cURL commands with Aspose.PDF Cloud API can offer flexibility and simplicity for integrating the feature into various programming languages and environments. Regardless of the approach you choose, Aspose.PDF Cloud offers robust and reliable tools for adding image and text to the footer section of your PDF documents.

We recommend visiting the following articles to learn about: