ByteScout PDF Suite - C# - Add header and footer with pdf sdk - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF Suite – C# – Add header and footer with pdf sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – C# – Add header and footer with pdf sdk

How to add header and footer with pdf sdk in C# and ByteScout PDF Suite

Learn to code in C# to add header and footer with pdf sdk with this step-by-step tutorial

These sample source codes on this page below are displaying how to add header and footer with pdf sdk in C#. ByteScout PDF Suite can add header and footer with pdf sdk. It can be applied from C#. ByteScout PDF Suite is the bundle that provides six different SDK libraries to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.

Want to quickly learn? This fast application programming interfaces of ByteScout PDF Suite for C# plus the guidelines and the code below will help you quickly learn how to add header and footer with pdf sdk. Just copy and paste the code into your C# application’s code and follow the instructions. Further improvement of the code will make it more robust.

Trial version of ByteScout PDF Suite is available for free. Source code samples are included to help you with your C# app.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using Bytescout.PDF; using System; using System.Diagnostics; using Font = Bytescout.PDF.Font; using SolidBrush = Bytescout.PDF.SolidBrush; namespace AddHeaderAndFooter { class Program { static void Main(string[] args) { try { using (Document doc = new Document()) { doc.RegistrationName = "demo"; doc.RegistrationKey = "demo"; doc.Load("sample.pdf"); // Prepare simple template (for example, a logo) and draw it on every page // Create template of specified size GraphicsTemplate headerTemplate = new GraphicsTemplate(250, 50); headerTemplate.DrawString("Here is a header text", new Font(StandardFonts.CourierBold, 15), new SolidBrush(), 30, 10); GraphicsTemplate footerTemplate = new GraphicsTemplate(250, 50); footerTemplate.DrawString("Here is the footer text", new Font(StandardFonts.CourierBold, 15), new SolidBrush(), 30, 10); // Write template in each pages for (int i = 0; i < doc.Pages.Count; i++) { Page currentPage = doc.Pages[i]; currentPage.Canvas.DrawTemplate(headerTemplate, 40, 10); currentPage.Canvas.DrawTemplate(footerTemplate, 350, (currentPage.Height - 40)); } // Save output file doc.Save("result.pdf"); } // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press enter key to exit..."); Console.ReadLine(); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next