Re: Export to PDF

Hello Albert,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

You can use the contents of Spreadsheet in fields over Pdf document. First you need to export the contents of worksheet into DataTable object using Aspose.Cells and than use AutoFiller class in Aspose.pdf.kit to fill the deginated fields in pdf.

Please use the following code snippet,

Workbook workbook = new Workbook();
//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);
//Opening the Excel file through the file stream
workbook.Open(fstream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Exporting the contents of 7 rows and 2 columns starting from 1st cell to DataTable
DataTable dataTable = worksheet.Cells.ExportDataTable(0, 0, 7, 2, true);
//Binding the DataTable with DataGrid
dataGrid1.DataSource = dataTable;
//Closing the file stream to free all resources
fstream.Close();

// Create an object of AutoFiller class
AutoFiller autoFiller = new AutoFiller();
// The input pdf file that contains form fields
autoFiller.InputFileName = "C:\\pdftest\\DataTableExample.pdf";
// The resultant pdf, that will contain the form fields filled with information from DataTable
autoFiller.OutputFileName = "C:\\pdftest\\outputFile.pdf";
// call the method to import the data from DataTable object into Pdf form fields.
autoFiller.ImportDataTable(dataTable);
// call the save method to generate the pdf file
autoFiller.Save();

Make sure that, the Column name of DataTable is same as field name over Pdf file. I have created the Pdf file with form fields using Aspose.Pdf. Resource files used in code snippet are in attachment, please take a review.

For information on how to export worksheet data please visit Exporting Data from Worksheets

For information on filling form fields using AutoFiller class please visit AutoFiller

For information on creating form field using Aspose.pdf, pelase visit Manipulating Form Fields

Hello Albert,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

You can use the contents of Spreadsheet in fields over Pdf document. First you need to export the contents of worksheet into DataTable object using Aspose.Cells and than use AutoFiller class in Aspose.pdf.kit to fill the deginated fields in pdf.

Please use the following code snippet,

Workbook workbook = new Workbook();
//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);
//Opening the Excel file through the file stream
workbook.Open(fstream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Exporting the contents of 7 rows and 2 columns starting from 1st cell to DataTable
DataTable dataTable = worksheet.Cells.ExportDataTable(0, 0, 7, 2, true);
//Binding the DataTable with DataGrid
dataGrid1.DataSource = dataTable;
//Closing the file stream to free all resources
fstream.Close();

// Create an object of AutoFiller class
AutoFiller autoFiller = new AutoFiller();
// The input pdf file that contains form fields
autoFiller.InputFileName = "C:\\pdftest\\DataTableExample.pdf";
// The resultant pdf, that will contain the form fields filled with information from DataTable
autoFiller.OutputFileName = "C:\\pdftest\\outputFile.pdf";
// call the method to import the data from DataTable object into Pdf form fields.
autoFiller.ImportDataTable(dataTable);
// call the save method to generate the pdf file
autoFiller.Save();

Make sure that, the Column name of DataTable is same as field name over Pdf file. I have created the Pdf file with form fields using Aspose.Pdf. Resource files used in code snippet are in attachment, please take a review.

For information on how to export worksheet data please visit Exporting Data from Worksheets

For information on filling form fields using AutoFiller class please visit AutoFiller

For information on creating form field using Aspose.pdf, pelase visit Manipulating Form Fields