Exporting to PDF from a database

CenoPDF can create a template and use a database to populate fields in the template to batch create PDF forms. Any database product such as SQL Server, Access, Excel etc, as long as it can provide a connection string, it can be used in CenoPDF. For more information please see Export to PDF from Database dialog box.

This walkthrough demonstrates the steps to batch create PDF forms using the data in an Excel spreadsheet. Each row of the spreadsheet creates one PDF file. The text boxes and radio buttons on the PDF file are filled with the data from that row. The files used in this walkthrough can be downloaded here: Template.docand Book1.xls.

  1. Use Microsoft Word to create the template file Template.doc. There are three text boxes and two radio buttons in the file. Their names are firstname, lastname,street andjob. Note that two radio buttons share the same name but they export different values, job1 and job2.

    Template document file

  2. Use Microsoft Excel to create a spreadsheet, Book1.xls, which will serve as a database. The first row is column names. If you want to use the data in a PDF field, its column name must be in the format of fieldname_propertyname for a regular field or fieldname_propertyname_index for radio buttons.

    For a text box, the Text property is most frequently used. In our example, the column names are firstname_Text, lastname_Textand street_Text corresponding to the template file.

    For radio buttons, because many radio buttons can share the same name, you have to append an index to the field name to distinguish them. The index is same as the tab order in the same group of radio buttons. In our example, we want to set which button is checked. So the column names are job_DefaultIsChecked_0 for the job1 button and job_DefaultIsChecked_0 for the job2 button.

    Microsoft Excel spreadsheet serves as database

  3. If you want see other property names besides the ones used in this example, you can choose CenoPDF > Options > General and check Always use property grid to edit field properties box. Edit properties of a PDF field, you will see all property names at left side of the grid.

  4. In Microsoft Word, choose command CenoPDF> Export to PDF from Database. Copy and paste the following text into the Connection String box:

    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\myfolder\Book1.xls;Extended Properties="Excel 8.0;HDR=YES;"

    If your file is in Excel 2007 format (.xlsx), use this connection string:

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myfolder\Book1.xlsx;Extended Properties="Excel 12.0;HDR=YES;"
    (Install 2007 Office System Driver: Data Connectivity Components if it gives you any error.)

    Note You must change the path of Data Source to the real path in your computer.

  5. For Excel spreadsheet, a table name is the sheet name plus a dollar sign. So type Sheet1$ into the Table Name box. If you use Microsoft SQL server, the dollar sign is not needed.
  6. Click the Test button. You should see your data in the Database Contents grid.

    Batch export

  7. Type C:\PDFOutput\[firstname_Text][count].pdfinto Output PDF File Path Pattern box and click the OK button. Ten PDF files are generated at the path you specified.

    The list of files generated from database

See also
Export to PDF from Database dialog box.