Convert table in PDF to XML file in C#, VB.NET, VBScript using PDF Extractor SDK - ByteScout

Convert table in PDF to XML file in C#, VB.NET, VBScript using PDF Extractor SDK

  • Home
  • /
  • Articles
  • /
  • Convert table in PDF to XML file in C#, VB.NET, VBScript using PDF Extractor SDK

These samples show how to extract PDF table to XML (eXtensible Markup Language) file using Bytescout PDF Extractor SDK.

Select your programming language:

In these screenshots you can see input PDF table and output XML file with data extracted from the table.

Input PDF table to be converted to XML file Input PDF file
Output XML file with data extracted from PDF table Output XML file

C#

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.PDFExtractor;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create Bytescout.PDFExtractor.XMLExtractor instance
            XMLExtractor extractor = new XMLExtractor();
            extractor.RegistrationName = "demo";
            extractor.RegistrationKey = "demo";

            // Load sample PDF document
            extractor.LoadDocumentFromFile("sample3.pdf");

            extractor.SaveXMLToFile("output.XML");

            Console.WriteLine();
            Console.WriteLine("Data has been extracted to 'output.XML' file.");
            Console.WriteLine();
            Console.WriteLine("Press any key to continue and open XML in default XML viewer)...");
            Console.ReadKey();

            Process.Start("output.XML");
        }
    }
}

VB.NET

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Bytescout.PDFExtractor
Imports System.Diagnostics

Namespace ConsoleApplication1
    Class Program
        Shared Sub Main(ByVal args As String())
            ' Create Bytescout.PDFExtractor.XMLExtractor instance
            Dim extractor As New XMLExtractor()
            extractor.RegistrationName = "demo"
            extractor.RegistrationKey = "demo"

            ' Load sample PDF document
            extractor.LoadDocumentFromFile("sample3.pdf")

            extractor.SaveXMLToFile("output.XML")

            Console.WriteLine()
            Console.WriteLine("Data has been extracted to 'output.XML' file.")
            Console.WriteLine()
            Console.WriteLine("Press any key to continue and open XML in default XML viewer)...")
            Console.ReadKey()

            Process.Start("output.XML")
        End Sub
    End Class
End Namespace

VBScript (Visual Basic 6)

' Create Bytescout.PDFExtractor.XMLExtractor object
Set extractor = CreateObject("Bytescout.PDFExtractor.XMLExtractor")

extractor.RegistrationName = "demo"
extractor.RegistrationKey = "demo"

' Load sample PDF document
extractor.LoadDocumentFromFile "../../sample3.pdf"

extractor.SaveXMLToFile "output.XML"

MsgBox "Data has been extracted to 'output.xml' file."

Tutorials:

prev
next