ByteScout Premium Suite - VB.NET - Convert xml to pdf 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 Premium Suite – VB.NET – Convert xml to pdf with pdf sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – VB.NET – Convert xml to pdf with pdf sdk

How to convert xml to pdf with pdf sdk in VB.NET with ByteScout Premium Suite

Learn to convert xml to pdf with pdf sdk in VB.NET

ByteScout simple and easy to understand tutorials are planned to describe the code for both VB.NET beginners and advanced programmers. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording and you can use it to convert xml to pdf with pdf sdk with VB.NET.

The SDK samples given below describe how to quickly make your application do convert xml to pdf with pdf sdk in VB.NET with the help of ByteScout Premium Suite. Simply copy and paste in your VB.NET project or application you and then run your app! Further improvement of the code will make it more robust.

The trial version of ByteScout Premium Suite can be downloaded for free from our website. It also includes source code samples for VB.NET and other programming languages.

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 System.Xml Imports Bytescout.PDF ''' <summary> ''' This example demonstrates how to create table from some XML data. ''' Since your XML file has different structure the example just shows technique of XML data reading ''' and PDF table creation. ''' </summary> Class Program Shared Sub Main() ' Load XML document Dim xmlDocument = New XmlDocument() xmlDocument.Load("sample.xml") ' Read columns information from XML data Dim columns = New List(Of String)() Dim columnNodeList = xmlDocument.SelectNodes("/Report/Columns/Column") For Each node As XmlNode In columnNodeList columns.Add(node.Attributes("Name").Value) Next ' Read row nodes from XML data Dim rowNodeList = xmlDocument.SelectNodes("/Report/ReportData") ' Create new PDF document Dim pdfDocument = New Document() pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" ' Add page Dim page = New Page(PaperFormat.A4) pdfDocument.Pages.Add(page) Dim lightGrayColor = New ColorGray(200) Dim whiteColor = New ColorGray(255) ' Create PDF table Dim table = New Table() table.BackgroundColor = lightGrayColor ' Add columns For c = 0 To columns.Count - 1 Dim column = New TableColumn(columns(c), columns(c)) ' Set column width column.Width = If(c = 0, 100, 60) table.Columns.Add(column) Next ' Add rows For Each rowNode As XmlNode In rowNodeList ' Create new row and set its background color Dim row = table.NewRow() row.BackgroundColor = whiteColor ' Get cell values from XML data For Each childNode As XmlNode In rowNode.ChildNodes ' Get cell info from XML data Dim columnName = childNode.Name Dim columnIndex = columns.IndexOf(childNode.Name) Dim cellValue = childNode.InnerText ' Set cell text row(columnName).Text = cellValue ' Set cell text alignment row(columnName).TextFormat.HorizontalAlign = If(columnIndex = 0, HorizontalAlign.Left, HorizontalAlign.Right) Next ' Add the row to the table table.Rows.Add(row) Next ' Draw the table on canvas page.Canvas.DrawTable(table, 20, 20) ' Save document to file pdfDocument.Save("result.pdf") ' Cleanup pdfDocument.Dispose() ' Open document in default PDF viewer application Process.Start("result.pdf") End Sub End Class

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium 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 Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next