ByteScout PDF SDK - VB.NET - Add Page Numbers to PDF - ByteScout

ByteScout PDF SDK – VB.NET – Add Page Numbers to PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – Add Page Numbers to PDF

How to add page numbers to PDF in VB.NET and ByteScout PDF SDK

The tutorial below will demonstrate how to add page numbers to PDF in VB.NET

Learn how to add page numbers to PDF in VB.NET 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 page numbers to PDF using VB.NET.

You will save a lot of time on writing and testing code as you may just take the VB.NET code from ByteScout PDF SDK for add page numbers to PDF below and use it in your application. In your VB.NET project or application you may simply copy & paste the code and then run your app! Enjoy writing a code with ready-to-use sample codes in VB.NET.

Our website provides trial version of ByteScout PDF SDK for free. It also includes documentation and source code samples.

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

Program.vb
      
Imports Bytescout.PDF Imports Font = Bytescout.PDF.Font Imports SolidBrush = Bytescout.PDF.SolidBrush Module Program #Region "Declarations" Private Enum PageNoStyle TopLeft TopRight BottomLeft BottomRight End Enum #End Region Sub Main() Try Using doc As Document = New Document() ' Add registration keys doc.RegistrationName = "demo" doc.RegistrationKey = "demo" ' Load document doc.Load("sample.pdf") ' Write template in each pages For i As Integer = 0 To doc.Pages.Count - 1 Dim currentPage As Page = doc.Pages(i) _AddPageNo(currentPage, "Page #" & (i + 1), PageNoStyle.BottomRight) Next ' Save output file doc.Save("result.pdf") End Using ' Open output file Process.Start("result.pdf") Catch ex As Exception Console.WriteLine(ex.Message) Console.WriteLine("Press enter key to exit...") Console.ReadLine() End Try End Sub ''' <summary> ''' Add Page No ''' </summary> Private Sub _AddPageNo(ByVal currentPage As Page, ByVal pageNoText As String, ByVal pageNoStyle As PageNoStyle) Dim float_left As Single = 10 Dim float_top As Single = 10 Select Case pageNoStyle Case PageNoStyle.TopRight float_left = currentPage.Width - 60 Case PageNoStyle.BottomLeft float_top = currentPage.Height - 20 Case PageNoStyle.BottomRight float_top = currentPage.Height - 20 float_left = currentPage.Width - 60 Case Else End Select ' Draw/Write page no currentPage.Canvas.DrawString( pageNoText, New Font(StandardFonts.CourierBold, 12), New SolidBrush(), float_left, float_top) End Sub End Module

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