ByteScout PDF SDK - C# - Add Header And Footer - ByteScout

ByteScout PDF SDK – C# – Add Header And Footer

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Add Header And Footer

How to add header and footer in C# and ByteScout PDF SDK

How to add header and footer in C#

Learn how to add header and footer in C# with this source code sample. ByteScout PDF SDK is the library for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings. It can be used to add header and footer using C#.

C# code samples for C# developers help to speed up coding of your application when using ByteScout PDF SDK. In order to implement the functionality, you should copy and paste this code for C# below into your code editor with your app, compile and run your application. Detailed tutorials and documentation are available along with installed ByteScout PDF SDK if you’d like to dive deeper into the topic and the details of the API.

ByteScout free trial version is available for download from our website. It includes all these programming tutorials along with source code samples.

Try ByteScout PDF SDK today: Get 60 Day Free Trial or sign up for Web API

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(); } } }

Try ByteScout PDF SDK today: 60 Day Free Trial (on-premise version) or sign up for Web API (on demand version)

VIDEO

ON-PREMISE VERSION

Get 60 Day Free Trial or Visit ByteScout PDF SDK page

Explore ByteScout PDF SDK documentation

WEB API

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next