ExportToPDF .NET assembly (for VB.NET, C#, C++)

ExportToPDF is a PDF development .NET assembly designed especially to help you develop PDF conversion .NET application with very minimum efforts. It takes several lines of codes to generate PDF document from a data source like CSV, Excel, delimited text file, MS Access database, .NET DataTable object and complete your programming project.

 

ExportToPDF.dll is a .NET component library for developers to implement conversion to PDF process software solutions. ExportToPDF provides a single API class with a bunch of very customizable properties to create, manipulate, and organize PDF documents from within your .NET applications.

ExportToPDF is .NET library that offers the ability to convert csv files, Excel spreadsheets, Access mdb databases, text files, .NET DataTable objects to PDF on the fly. If you need PDF reports you do not have to use complex report generators anymore. Just create a simple .NET Windows Form or ASP.NET page and export it to PDF with the ExportToPDF assembly.
 

  Download demo-trial now!

RustemSoft presents the 'file to PDF' conversion package, named ExportToPDF .NET assembly that accomplishes conversion, formatting, PDF content merging, font settings, text coloring and other PDF tasks. Download Trial sample PDF Converter project that demonstrate the use of the Export to PDF class and show the results of using the class in several examples.

  • Setup ASP.NET web sample project

  • Convert SQL Server database query to PDF

  • Convert Text file to PDF

  • Convert Excel spreadsheet to PDF

  • Add a Reference for Visual Studio .NET project

  •  

     
    Order the ExportToPDF assembly

    Read the ExportToPDF assembly documentation

    Hot Queston

    This is an awesome product it gives my application and its users a lot of flexibility. This add-on makes it real easy for the developer to provide a multitude of formats to turn into the world's most widely used format. This product allows great flexibility to easily output beautiful documents and it is fully customizable as well. Words cannot even describe how useful and powerful this product truly is!
    Ryan J. Birnesser
    Systems Software Designer/Programmer
    Pioneer Pole Buildings, Inc.
    Schuylkill Haven, PA

     

    Skater .NET Obfuscator
    More about Skater .NET Obfuscator
    Download Skater .NET Obfuscator
    Order Skater .NET Obfuscator
     

    DataGridViewColumns .NET assembly
    More about DataGridViewColumns.dll
    Download DataGridViewColumns.dll
    Order DataGridView Columns
     

     

     
     

    Convert SQL Server database query to PDF

    ExportToPDF is helpful to export your SQL Server query result into a formatted PDF file. For this case SourceType property of RustemSoft.ExportToPDF.Export class object has to be signed as SourceTypes.DataTable. Then the SQL query result should be populated to System.Data.DataTable object. ExportToPDF just converts the DataTable object to PDF.
     

    VB .NET

     

    Imports System.Data

    Imports RustemSoft.ExportToPDF

    Imports System.Data.SqlClient

    ...

    Dim ExportToPDFobject As New RustemSoft.ExportToPDF.Export

    Dim Connection As String = "Initial Catalog=[MyDatabaseName];Data Source=[MySQLServerName];UID=[MyUserID];PWD=[psw]"
    Dim conn As New SqlConnection(Connection)
    conn.Open()
    Dim strSQL As String = "SELECT * from MyTable"
    Dim cmdMyTable As New SqlCommand(strSQL, conn)
    cmdMyTable.CommandType = CommandType.Text
    cmdMyTable.CommandTimeout = 6000
    ' Create a SqlDataAdapter for the MyTable table
    Dim tblMyTable As DataTable = New DataTable
    Dim adpMyTable As SqlDataAdapter = New SqlDataAdapter
    adpMyTable.SelectCommand = cmdMyTable
    adpMyTable.Fill(tblMyTable)
    ExportToPDFobject.SourceType = SourceTypes.DataTable
    ExportToPDFobject.DataSourceTable = tblMyTable

    ExportToPDFobject.outputFileName = "C:\MyDirectory\MyTable.pdf"

    ' Assign specific ExportToPDFobject's PDF formatting, coloring, and others properties
    ...

    ' Run conversion to PDF
    ExportToPDFobject.Convert()

    conn.Close()

     

    C#

     

    using System.Data;

    using RustemSoft.ExportToPDF;

    using System.Data.SqlClient;

    ...

    RustemSoft.ExportToPDF.Export ExportToPDFobject = new RustemSoft.ExportToPDF.Export();

    string Connection = "Initial Catalog=[MyDatabaseName];Data Source=[MySQLServerName];UID=[MyUserID];PWD=[psw]";
    SqlConnection conn = new SqlConnection(Connection);
    conn.Open();
    string strSQL = "SELECT * from MyTable";
    SqlCommand cmdMyTable = new SqlCommand(strSQL, conn);
    cmdMyTable.CommandType = CommandType.Text;
    cmdMyTable.CommandTimeout = 6000;
    // Create a SqlDataAdapter for the MyTable table
    DataTable tblMyTable = new DataTable();
    SqlDataAdapter adpMyTable = new SqlDataAdapter();
    adpMyTable.SelectCommand = cmdMyTable;
    adpMyTable.Fill(tblMyTable);
    ExportToPDFobject.SourceType = SourceTypes.DataTable;
    ExportToPDFobject.DataSourceTable = tblMyTable;

    ExportToPDFobject.outputFileName = "C:\\MyDirectory\\MyTable.pdf";

    // Assign specific ExportToPDFobject's PDF formatting, coloring, and others properties
    ...

    // Run conversion to PDF
    ExportToPDFobject.Convert();

    conn.Close();

     


     
     

    Convert Text file to PDF

    You have a plain text file where data stored in several columns delimited by a special char. By using ExportToPDF Export class special DataSeparatorChar property you can specify the delimiter char. By default the property value is Tab (ASCII 9). So data presented in your text file will be transformed into PDF document with text, layout, and other settings you are applying for PDF conversion.
     

    VB .NET

     

    Imports RustemSoft.ExportToPDF

    ...

    ' Define new ExportToPDF.Export class object
    Dim ExportToPDFobject As New RustemSoft.ExportToPDF.Export

    ' Define SourceType property as Txt
    ExportToPDFobject.SourceType = SourceTypes.Txt
    ' Specify data source file location
    ExportToPDFobject.inputFileName = "C:\MyDirectory\MyText.txt"
    ' Specify PDF output file path
    ExportToPDFobject.outputFileName = "C:\MyDirectory\My.pdf"

    ' Assign ExportToPDFobject's properties
    ' Specify grid appearance on PDF
    ExportToPDFobject.grid = True
    ExportToPDFobject.gridWidth = 0.1
    ExportToPDFobject.gridColor = Color.Gray

    ' Specify PDF document text font, size, and color
    ExportToPDFobject.font = pdfFont.Helvetica
    ExportToPDFobject.fontSize = 1
    ExportToPDFobject.textColor = Color.Black

    ' Define columns headers' specific properties
    ExportToPDFobject.HeadersOnEachPage = True
    ExportToPDFobject.HeadersFont = pdfFont.Helvetica_BoldOblique
    ExportToPDFobject.HeadersTextColor = Color.Red

    ' Specify PDF document title text, font, size, and color
    ExportToPDFobject.Title = "Title"
    ExportToPDFobject.TitleFont = pdfFont.Times_Roman
    ExportToPDFobject.TitleFontSize = 5
    ExportToPDFobject.TitleColor = Color.Green

    ' Specify PDF document footer text, font, size, and color
    ExportToPDFobject.Footer = "Footer"
    ExportToPDFobject.FooterFont = pdfFont.Times_Roman
    ExportToPDFobject.FooterFontSize = 5
    ExportToPDFobject.FooterColor = Color.Brown

    ' Specify PDF document layout properties
    ExportToPDFobject.pageMarginLeft = 20
    ExportToPDFobject.pageMarginRight = 10
    ExportToPDFobject.pageMarginTop = 50
    ExportToPDFobject.pageMarginBottom = 50
    ExportToPDFobject.pageWidth = 0
    ExportToPDFobject.pageHeight = 0
    ExportToPDFobject.pageLinesCount = 0
    ExportToPDFobject.Landscape = False

    ' Run conversion to PDF
    ExportToPDFobject.Convert()

     

    C#

     

    using RustemSoft.ExportToPDF;

    ...

    // Define new ExportToPDF.Export class object
    RustemSoft.ExportToPDF.Export ExportToPDFobject = new RustemSoft.ExportToPDF.Export();

    // Define SourceType property as Txt
    ExportToPDFobject.SourceType = SourceTypes.Txt;
    // Specify data source file location
    ExportToPDFobject.inputFileName = "C:\\MyDirectory\\MyText.txt";
    // Specify PDF output file path
    ExportToPDFobject.outputFileName = "C:\\MyDirectory\\My.pdf";

    // Assign ExportToPDFobject's properties
    // Specify grid appearance on PDF
    ExportToPDFobject.grid = true;
    ExportToPDFobject.gridWidth = 0.1;
    ExportToPDFobject.gridColor = Color.Gray;

    // Specify PDF document text font, size, and color
    ExportToPDFobject.font = pdfFont.Helvetica;
    ExportToPDFobject.fontSize = 1;
    ExportToPDFobject.textColor = Color.Black;

    // Define columns headers' specific properties
    ExportToPDFobject.HeadersOnEachPage = true;
    ExportToPDFobject.HeadersFont = pdfFont.Helvetica_BoldOblique;
    ExportToPDFobject.HeadersTextColor = Color.Red;

    // Specify PDF document title text, font, size, and color
    ExportToPDFobject.Title = "Title";
    ExportToPDFobject.TitleFont = pdfFont.Times_Roman;
    ExportToPDFobject.TitleFontSize = 5;
    ExportToPDFobject.TitleColor = Color.Green;

    // Specify PDF document footer text, font, size, and color
    ExportToPDFobject.Footer = "Footer";
    ExportToPDFobject.FooterFont = pdfFont.Times_Roman;
    ExportToPDFobject.FooterFontSize = 5;
    ExportToPDFobject.FooterColor = Color.Brown;

    // Specify PDF document layout properties
    ExportToPDFobject.pageMarginLeft = 20;
    ExportToPDFobject.pageMarginRight = 10;
    ExportToPDFobject.pageMarginTop = 50;
    ExportToPDFobject.pageMarginBottom = 50;
    ExportToPDFobject.pageWidth = 0;
    ExportToPDFobject.pageHeight = 0;
    ExportToPDFobject.pageLinesCount = 0;
    ExportToPDFobject.Landscape = false;

    // Run conversion to PDF
    ExportToPDFobject.Convert();

     


     
     

    Convert Excel spreadsheet to PDF

    For Excel to PDF .NET conversion task you can transform by one spreadsheet in Excel file only. You have to specify the spreadsheet name by assigning value of SourceTableSheetName property. Also you can setup XlsConvertMode property to define what a type of Excel to PDF conversion you would like to implement.
    The property takes two conversion mode value.
    Fast - MS Excel spreadsheets will be transformed much faster. However this way is good if you have homogeneous (similar) data for each MS Excel sheet column. If you have different data types stored in the same column please do not select this option.
    Detailed - MS Excel spreadsheets will be transformed slowly. However this way is good if you have heterogeneous (different) data types values (numbers, date or text) stored together in some MS Excel spreadsheets field. Conversion to PDF will not lose this motley data.
    allowExcelHeaders property is useful to define if the spreadsheet’s column titles will be specified as column headers within generated PDF output file or not.

    VB .NET

     

    Imports RustemSoft.ExportToPDF

    ...

    ' Define new ExportToPDF.Export class object
    Dim ExportToPDFobject As New RustemSoft.ExportToPDF.Export

    ' Define SourceType property as Excel
    ExportToPDFobject.SourceType = SourceTypes.Excel
    ' Specify Excel conversion mode as Detailed
    ExportToPDFobject.XlsConvertMode = XlsConvertModes.Detailed
    ' Define that first row of spreadsheet is column headers on PDF document
    ExportToPDFobject.FirstRowIsHeaders = True
    ' Specify spreadsheet name within your Excel file that will be converted to PDF
    ExportToPDFobject.SourceTableSheetName = "Sheet1"
    ' Specify data source file location
    ExportToPDFobject.inputFileName = "C:\MyDirectory\MyExcel.xls"
    ' Specify PDF output file path
    ExportToPDFobject.outputFileName = "C:\MyDirectory\My.pdf"

    ' Assign ExportToPDFobject's properties
    ' Specify grid appearance on PDF
    ExportToPDFobject.grid = True
    ExportToPDFobject.gridWidth = 0.1
    ExportToPDFobject.gridColor = Color.Gray

    ' Specify PDF document text font, size, and color
    ExportToPDFobject.font = pdfFont.Helvetica
    ExportToPDFobject.fontSize = 1
    ExportToPDFobject.textColor = Color.Black

    ' Define columns headers' specific properties
    ExportToPDFobject.HeadersOnEachPage = True
    ExportToPDFobject.HeadersFont = pdfFont.Helvetica_BoldOblique
    ExportToPDFobject.HeadersTextColor = Color.Red

    ' Specify PDF document title text, font, size, and color
    ExportToPDFobject.Title = "Title"
    ExportToPDFobject.TitleFont = pdfFont.Times_Roman
    ExportToPDFobject.TitleFontSize = 5
    ExportToPDFobject.TitleColor = Color.Green

    ' Specify PDF document footer text, font, size, and color
    ExportToPDFobject.Footer = "Footer"
    ExportToPDFobject.FooterFont = pdfFont.Times_Roman
    ExportToPDFobject.FooterFontSize = 5
    ExportToPDFobject.FooterColor = Color.Brown

    ' Specify PDF document layout properties
    ExportToPDFobject.pageMarginLeft = 20
    ExportToPDFobject.pageMarginRight = 10
    ExportToPDFobject.pageMarginTop = 50
    ExportToPDFobject.pageMarginBottom = 50
    ExportToPDFobject.pageWidth = 0
    ExportToPDFobject.pageHeight = 0
    ExportToPDFobject.pageLinesCount = 0
    ExportToPDFobject.Landscape = False

    ' Run conversion to PDF
    ExportToPDFobject.Convert()

     

    C#

     

    using RustemSoft.ExportToPDF;

    ...

    // Define new ExportToPDF.Export class object
    RustemSoft.ExportToPDF.Export ExportToPDFobject = new RustemSoft.ExportToPDF.Export();

    // Define SourceType property as Excel
    ExportToPDFobject.SourceType = SourceTypes.Excel;
    // Specify data source file location
    ExportToPDFobject.inputFileName = "C:\\MyDirectory\\MyExcel.xls";
    // Specify Excel conversion mode as Detailed
    ExportToPDFobject.XlsConvertMode = XlsConvertModes.Detailed;
    // Define that first row of spreadsheet is column headers on PDF document
    ExportToPDFobject.FirstRowIsHeaders = true;
    // Specify spreadsheet name within your Excel file that will be converted to PDF
    ExportToPDFobject.SourceTableSheetName = "Sheet1";
    // Specify PDF output file path
    ExportToPDFobject.outputFileName = "C:\\MyDirectory\\My.pdf";

    // Assign ExportToPDFobject's properties
    // Specify grid appearance on PDF
    ExportToPDFobject.grid = true;
    ExportToPDFobject.gridWidth = 0.1;
    ExportToPDFobject.gridColor = Color.Gray;

    // Specify PDF document text font, size, and color
    ExportToPDFobject.font = pdfFont.Helvetica;
    ExportToPDFobject.fontSize = 1;
    ExportToPDFobject.textColor = Color.Black;

    // Define columns headers' specific properties
    ExportToPDFobject.HeadersOnEachPage = true;
    ExportToPDFobject.HeadersFont = pdfFont.Helvetica_BoldOblique;
    ExportToPDFobject.HeadersTextColor = Color.Red;

    // Specify PDF document title text, font, size, and color
    ExportToPDFobject.Title = "Title";
    ExportToPDFobject.TitleFont = pdfFont.Times_Roman;
    ExportToPDFobject.TitleFontSize = 5;
    ExportToPDFobject.TitleColor = Color.Green;

    // Specify PDF document footer text, font, size, and color
    ExportToPDFobject.Footer = "Footer";
    ExportToPDFobject.FooterFont = pdfFont.Times_Roman;
    ExportToPDFobject.FooterFontSize = 5;
    ExportToPDFobject.FooterColor = Color.Brown;

    // Specify PDF document layout properties
    ExportToPDFobject.pageMarginLeft = 20;
    ExportToPDFobject.pageMarginRight = 10;
    ExportToPDFobject.pageMarginTop = 50;
    ExportToPDFobject.pageMarginBottom = 50;
    ExportToPDFobject.pageWidth = 0;
    ExportToPDFobject.pageHeight = 0;
    ExportToPDFobject.pageLinesCount = 0;
    ExportToPDFobject.Landscape = false;

    // Run conversion to PDF
    ExportToPDFobject.Convert();

     


     
     

    Add a Reference for Visual Studio .NET project

    Suppose you are building a project using Visual Studio.NET, and you decide that you want to start consuming RustemSoft ExportToPDF .NET assembly in your .NET project. The first step that you will generally take is, you will add a reference to the ExportToPDF .NET assembly, which is residing in some directory on your PC hard drive. Visual Studio .NET will then add a new item under Solution Explorer called 'References', and it will create a row node underneath it called ExportToPDF.
    In order to add the reference to ExportToPDF .NET assembly please follow the steps:

    Select Project from the menu bar
    Choose Add Reference from the drop down menu
    Click on the Browse button
    Browse to and choose ExportToPDFTrial.dll

    The Reference to a .NET RustemSoft namespace is a requirement and must be added to a project before the objects in the RustemSoft namespace can be used. The VB .NET Imports statement (or C# using statement) is not a requirement and is simply a coding convenience that allows shorter names to be used. You can add the statement to your code:

    VB .NET
    Imports RustemSoft.ExportToPDF

    C#
    using RustemSoft.ExportToPDF;

    C++
    #using <ExportToPDFTrial.dll>
    using namespace RustemSoft;
     

    Download the ExportToPDF .NET assembly code samples for VB.NET and C# that show how you can use the RustemSoft ExportToPDF conversion in your .NET project.
     


     
     

    Setup ASP.NET web sample project

    To work with ASP.NET Web sample application (WebPDFConverterVB or WebPDFConverterCS depending on what language you prefer) please follow the steps:

    Open MS .NET Development Environment (Visual Studio 2005 or later) and create a new Web Site
    In 'Location' combobox select 'File System'
    In 'Language' combobox select language that you prefer (Visual Basic or Visual C#)
    Go to WebPDFConverterVB or WebPDFConverterCS folder of the installed evaluation package and select all files and folders in that folder
    Copy and paste selected files and folders into the new Web Site's directory. For example, you created the new Web Site in C:\WebSite1 folder. Place the sample web application files and folders into that directory
    You are good to run the web sample project