PDF Toolkit

Samples

Convert a CSV file to PDF

Take a Comma Separated Value (CSV) file and convert it to a table in a PDF file

This Code sample requires the PDF Toolkit and is found in: C:\Aquaforest\PDF Toolkit\samples\CSVToPDF

    
using Aquaforest.PDF;
using Aquaforest.PDF.Font;
    
namespace CSVToPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            CSVToPDFConverter csv = new CSVToPDFConverter(@"..\..\..\documents\source\csv_input.csv");
                
            // The page settings of the output PDF
            PDFPageSettings pageSettings = new PDFPageSettings();
            pageSettings.Font = PDFType1Font.HELVETICA;
            pageSettings.FontSize = 12;
            pageSettings.SetMargin(50, 50, 50, 50);
            pageSettings.SetSize(PageSize.A4);
    
            // The settings of the table in the output PDF
            PDFTableSettings tableSettings = new PDFTableSettings()
            {
                CellMargin = 5,
                RowHeight = 20
            };
    
            csv.ConvertToPDF(@"..\..\..\documents\output\csv_output.pdf", pageSettings, tableSettings);
        }
    }
}