PDF Definition
Overview
In this lesson, we are going to generate PDF documents using templates that we can select in order to convert the files. Wayfast can use Dynamic-link library (DLL) that are capable to generate the PDF in our application using the information retrieved from stored procedure in Database.
How to create a template in PDF Editor?
At the beginning, we need to create a template in any PDF Editor where we can include all the fields that we want in the document. In this example, we will use Acrobat to design the header and sections with their corresponding input fields that we need to associate in Wayfast with the database.
Let’s prepare a new form including labels and input fields. It’s important to be accurate in the values that we are going to include because this tags are going to be mapped through the Stored Procedure in Database.
Once the form is generated, we can continue the process in Wayfast.
How to create a new PDF Definition in Wayfast based on Stored Procedure?
Precondition: Requirement needs to be active in Project for new PDF Definition
Before creating a PDF Definition, we need to analyze the basic considerations to generate the Stored Procedure with all the parameters related to the template that have to be completed based on the Database information.
Normally we don’t have all the fields that we want in our document at the same Database table, that’s the reason why the stored procedure should contain multiple queries and temporary tables to allocate the values gathering the information from different places in the database.
At the end, we need to return the mapped values exactly as we defined in the PDF Template.
Once the stored procedure is created and synchronized in Wayfast, click on “Connectors” header icon and then select “PDF Definition” tab
PDF Definition dashboard is displayed on screen
You can find the details of each object generated with their corresponding stored procedure. If we need to edit the PDF Definition, click on “PDF Name” link and a popup will be displayed with the details available.
Let’s create a new PDF Definition based on the template created in the Editor. Click on “New” button on PDF Definition section
It’s important to point the correct “Instance” and “Stored Procedure” regarding the conditions previously established. This setting will be the key for each of the input fields that needs to be filled in PDF.
Another important value to include is the PDF example that we need to attach into the PDF Definition. Click on “Accept” button and the new row should be added in Wayfast.
Click on “See detail” lookup icon at the dashboard
A popup is displayed with 2 columns where the mapping connection is established between the PDF and stored procedure. Another column to take a look is the “Link to Run” because that’s the URL generated by the DLL to use in the web application to generate the PDF file.
Generate “Print PDF” button in the web application
Now that we generated the template and setup the PDF Definition, we need to use the configuration into the developed application.
Turn to “Project Pages” header icon and focus on “Controls” section
Select “Button” control in dropdown list and then click on “New” button
Complete the required fields using the “Link to Run” details from PDF Definition and including the parameters from the Stored Procedure associated.
Turn to “Conditional” tab and include a variable condition that involve the “ClientId” and “RequestType” pointing to specific values when clicking the button in the application.
Once the page is previewed, you can click on “Print to PDF” button and the popup will display the PDF file displayed on the screen and showing the correct information from Database.
Recap
In the first part of the lesson, we learnt how any template in PDF is our point to start mapping the information from Database through a Stored Procedure. In the second part, we used this PDF Definition from connectors inside any page that we want to use in the application. This action will trigger the generated file to export pdf. There are multiple possibilities using this Dynamic-link library (DLL) to create and connect professionally the data with our customers.