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.

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

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

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

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK 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 SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next