ByteScout PDF SDK - VB.NET - Create Invoice Spanning Multiple Page - ByteScout

ByteScout PDF SDK – VB.NET – Create Invoice Spanning Multiple Page

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – Create Invoice Spanning Multiple Page

How to create invoice spanning multiple page in VB.NET using ByteScout PDF SDK

The tutorial below will demonstrate how to create invoice spanning multiple page in VB.NET

On this page you will learn from code samples for programming in VB.NET.Writing of the code to create invoice spanning multiple page in VB.NET can be done by developers of any level using ByteScout PDF SDK. ByteScout PDF SDK can create invoice spanning multiple page. It can be used from VB.NET. ByteScout PDF SDK is the pdf library that can create, update and modify PDF files. Supports text with fonts and style selections, layers, form fields, drawing lines and objects, automatic tables, images. Can be used to create and fill pdf forms.

Fast application programming interfaces of ByteScout PDF SDK for VB.NET plus the instruction and the code below will help you quickly learn how to create invoice spanning multiple page. Follow the instructions from the scratch to work and copy the VB.NET code. You can use these VB.NET sample examples in one or many applications.

Trial version of ByteScout PDF SDK can be downloaded for free from our website. It also includes source code samples for VB.NET and other programming languages.

Try it today: Get 60 Day Free Trial or sign up for Web API

InvoiceDemo.VS2005.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>InvoiceDemo</RootNamespace> <AssemblyName>InvoiceDemo</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <ProductVersion>8.0.50727</ProductVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <ItemGroup> <Content Include="logo.png"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

InvoiceDemo.VS2008.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>InvoiceDemo</RootNamespace> <AssemblyName>InvoiceDemo</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <ProductVersion>9.0.30729</ProductVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <ItemGroup> <Content Include="logo.png"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

InvoiceDemo.VS2010.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>InvoiceDemo</RootNamespace> <AssemblyName>InvoiceDemo</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <ItemGroup> <Content Include="logo.png"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

InvoiceDemo.VS2012.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>InvoiceDemo</RootNamespace> <AssemblyName>InvoiceDemo</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <ItemGroup> <Content Include="logo.png"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

InvoiceDemo.VS2013.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>InvoiceDemo</RootNamespace> <AssemblyName>InvoiceDemo</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <ItemGroup> <Content Include="logo.png"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

InvoiceDemo.VS2015.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>InvoiceDemo</RootNamespace> <AssemblyName>InvoiceDemo</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <ItemGroup> <Content Include="logo.png"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

Program.vb
      
Imports Bytescout.PDF ''' <summary> ''' This example demonstrates how to create invoice which can span multiple pages. ''' </summary> Class Program #Region "Global Declarations" Const HeightConsumedByTableRow As Int32 = 20 Shared ContentHeightStart As Int32 = 100 Shared ContentHeightEnd As Int32 = 700 Shared HeightUtilized As Int32 = 100 Shared _RowCounter As Int32 = 1 Shared pdfDocument As Document Shared page As Page #End Region Shared Sub Main() #Region "Declarations and Implementations" Dim SolidPen As New SolidPen() Dim blackBrush As New SolidBrush(New ColorRGB(0, 0, 0)) Dim headerFont As New Font(StandardFonts.TimesBold, 24) Dim headerFont2 As New Font(StandardFonts.TimesBold, 16) Dim contentFont_12 As New Font(StandardFonts.TimesBold, 12) Dim contentFont_10 As New Font(StandardFonts.Times, 10) ' Create New document pdfDocument = New Document() pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" #End Region ' Add New page AddNewPage() ' 1. Add Content page.Canvas.DrawString("COMPANY NAME", contentFont_12, blackBrush, 50, HeightUtilized) HeightUtilized += 20 page.Canvas.DrawString("Address", contentFont_10, blackBrush, 50, HeightUtilized) page.Canvas.DrawString("DATE", contentFont_10, blackBrush, 400, HeightUtilized) HeightUtilized += 20 page.Canvas.DrawString("Phone, fax", contentFont_10, blackBrush, 50, HeightUtilized) page.Canvas.DrawString("INVOICE #", contentFont_10, blackBrush, 400, HeightUtilized) HeightUtilized += 20 page.Canvas.DrawString("E-mail", contentFont_10, blackBrush, 50, HeightUtilized) page.Canvas.DrawString("FOR", contentFont_10, blackBrush, 400, HeightUtilized) ' Add some vertical space HeightUtilized += 50 ' 2. Add Table which can span multipage Console.WriteLine("Enter the number of rows to add to the table:") Dim numberOfRows As Int32 = Convert.ToInt32(Console.ReadLine()) DrawTable(NumberOfRows:=numberOfRows) ' 3. Add Signature ' Check New page needed for adding signature If (CheckNewPageNeeded(70)) Then AddNewPage() End If page.Canvas.DrawString("Signature", contentFont_12, blackBrush, 400, (HeightUtilized + 57)) page.Canvas.DrawLine(SolidPen, 450, (HeightUtilized + 70), 570, (HeightUtilized + 70)) '4. Add Header And Footer For pageIndex = 0 To pdfDocument.Pages.Count - 1 Dim curPage As Page = pdfDocument.Pages(pageIndex) ' Add Logo Dim imageLogo As Image = New Image("logo.png") curPage.Canvas.DrawImage(imageLogo, 20, 45, imageLogo.Width / 2, imageLogo.Height / 2) ' Add requisites curPage.Canvas.DrawString("INVOICE", headerFont, blackBrush, 450, 55) ' Add Page Number curPage.Canvas.DrawLine(SolidPen, 20, 750, 590, 750) curPage.Canvas.DrawString({code}quot;Page: {pageIndex + 1} of {pdfDocument.Pages.Count}", contentFont_10, blackBrush, 30, 760) Next ' Save document to file pdfDocument.Save("result.pdf") ' Cleanup pdfDocument.Dispose() ' Open document in default PDF viewer app Process.Start("result.pdf") End Sub ''' <summary> ''' Checks whether new page is needed ''' </summary> ''' <param name="expectedHeight"></param> ''' <returns></returns> Shared Function CheckNewPageNeeded(expectedHeight As Int32) As Boolean Return (HeightUtilized + expectedHeight) > ContentHeightEnd End Function ''' <summary> ''' Adds new page, and also set height utilized ''' </summary> Shared Sub AddNewPage() ' Add page page = New Page(PaperFormat.Letter, PaperOrientation.Portrait) pdfDocument.Pages.Add(page) ' Reset Height Utilized HeightUtilized = ContentHeightStart End Sub ''' <summary> ''' Draw table ''' </summary> ''' <param name="NumberOfRows"></param> Shared Sub DrawTable(NumberOfRows As Int32) While (NumberOfRows > 0) ' Get number of rows can be added in current page Dim NumberOfRowsCanBeAddedInCurrentPage As Int32 = GetNumberOfRowsCanBeAddedInCurrentPage() If (NumberOfRowsCanBeAddedInCurrentPage > 0) Then Dim Table = GetTable(Math.Min(NumberOfRows, NumberOfRowsCanBeAddedInCurrentPage)) page.Canvas.DrawTable(Table, 50, HeightUtilized) ' Update Height Utilized HeightUtilized += (Math.Min(NumberOfRows, NumberOfRowsCanBeAddedInCurrentPage) * HeightConsumedByTableRow) NumberOfRows -= Math.Min(NumberOfRows, NumberOfRowsCanBeAddedInCurrentPage) Else ' Add New page AddNewPage() End If End While End Sub ''' <summary> ''' Get Table Header with Content ''' </summary> ''' <param name="NumberOfRows"></param> ''' <returns></returns> Shared Function GetTable(NumberOfRows As Int32) As Table Dim fontTableHeader As Font = New Font(StandardFonts.TimesBold, 11) Dim fontTableRow As Font = New Font(StandardFonts.Times, 10) Dim Table As New Table() ' 1. Add Table Header Table.Columns.Add(New TableColumn("Description", "Description")) Table.Columns(0).Width = 220 Table.Columns(0).Font = fontTableHeader Table.Columns(0).TextFormat.HorizontalAlign = HorizontalAlign.Left Table.Columns.Add(New TableColumn("Quantity", "Quantity")) Table.Columns(1).Width = 80 Table.Columns(1).Font = fontTableHeader Table.Columns(1).TextFormat.HorizontalAlign = HorizontalAlign.Right Table.Columns.Add(New TableColumn("Price", "Price")) Table.Columns(2).Width = 100 Table.Columns(2).Font = fontTableHeader Table.Columns(2).TextFormat.HorizontalAlign = HorizontalAlign.Right Table.Columns.Add(New TableColumn("Amount", "Amount")) Table.Columns(3).Width = 120 Table.Columns(3).Font = fontTableHeader Table.Columns(3).TextFormat.HorizontalAlign = HorizontalAlign.Right ' 2. Add Table Content For index = 0 To NumberOfRows - 1 ' Create New row And set its background color Dim row As TableRow = Table.NewRow() ' Set row header text row("Description").Text = {code}quot;Description For item - {_RowCounter}" row("Description").Font = fontTableRow row("Description").TextFormat.HorizontalAlign = HorizontalAlign.Left row("Quantity").Text = "###" row("Quantity").Font = fontTableRow row("Quantity").TextFormat.HorizontalAlign = HorizontalAlign.Right row("Price").Text = "$.
<!-- code block begin -->
    <h5>
      <strong>{codeFileName}</strong>
    </h5>
    
    <pre>
      <div class="code-editor {codeExtension}">{code}</div>
    </pre>

    <p>
        Try it today: <a class="btn btn-sm btn-default" href="https://bytescout.com/download/web-installer">Get 60 Day Free Trial</a> or <a class="btn btn-lg btn-primary" href="https://app.pdf.co/signup">sign up for Web API</a> 
    </p>    
            
<!-- code block end -->    

quot;
row("Price").Font = fontTableRow
row("Price").TextFormat.HorizontalAlign = HorizontalAlign.Right

row("Amount").Text = "$.

<!-- code block begin -->
    <h5>
      <strong>{codeFileName}</strong>
    </h5>
    
    <pre>
      <div class="code-editor {codeExtension}">{code}</div>
    </pre>

    <p>
        Try it today: <a class="btn btn-sm btn-default" href="https://bytescout.com/download/web-installer">Get 60 Day Free Trial</a> or <a class="btn btn-lg btn-primary" href="https://app.pdf.co/signup">sign up for Web API</a> 
    </p>    
            
<!-- code block end -->    

quot;
row("Amount").Font = fontTableRow
row("Amount").TextFormat.HorizontalAlign = HorizontalAlign.Right

' Add the row to the table
Table.Rows.Add(row)

' Increase _RowCounter
_RowCounter += 1
Next

Return Table

End Function

''' <summary>
''' Get number of rows can be added in current page
''' </summary>
''' <returns></returns>
Shared Function GetNumberOfRowsCanBeAddedInCurrentPage() As Integer
Return (ContentHeightEnd - HeightUtilized) / HeightConsumedByTableRow
End Function

End Class

Try it today: Get 60 Day Free Trial or sign up for Web API

MORE INFORMATION

Get 60 Day Free Trial or Visit ByteScout PDF SDK page

Explore ByteScout PDF SDK documentation

WEB API VERSION

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next