This tutorial guides how to add header to PDF with C# REST API. You will learn to automatically insert a header in PDF with C# Low Code API using a .NET-based Cloud SDK. It will assist you in setting and customizing the header contents including the formatting and positioning.
Prerequisite
- Create an account API credentials
- Download Aspose.PDF Cloud SDK for Dotnet to insert a header in a PDF file
- Setup C# project with the above SDK for working with headers
Steps to Add Header to PDF Document with C# RESTful Service
- Configure the PdfApi by setting the API key and application SID for adding a header
- Upload the target PDF file to cloud storage for working with the headers
- Create the TextHeader object and set the desired attributes including the text
- Call the PostDocumentTextHeader() method to insert the header in the PDF file
- Download the PDF file with headers in it
These steps define the process to add header to PDF file with C# REST Interface. Create the PdfApi class object, load the source PDF file to the Cloud, and create a TextHeader object by setting the text alignment, header alignment, text state, color, font, and header text. Call the PostDocumentTextHeader() method to insert the header and save the output PDF file with the new header.
Code to Insert Header in PDF with C# .NET-based API
This code has demonstrated the process to add a header to PDF with C# RESTful Service. The TextHeader contains other features such as links, background, opacity, flag to rotate, rotation angle, and zoom. Similarly, you can set the margin from the top, left, and right, underline, strikethrough, superscript, and subscript state of header text.
This article has taught us how to work with headers in a PDF file. To insert an image in a PDF file, refer to the article on Insert Image into PDF with C# REST API.