Sign In

PDF Form Filler

You can use AppSynergy's PDF Form Filler to automatically populate a PDF form with database data.

This feature works by calling an AppSynergy API. Please see Making RESTful API calls for details.


This example uses two stored procedures, one to map the fields into your PDF form (the request procedure), and one to save the filled PDF to your database (the callback procedure). You can create and manage stored procedures via Tools > Stored Routines.

Request Procedure - Map the Fields

Simply make a call to parasql_http() as shown below. Replace YOUR_API_KEY with an actual API key you create via Tools > API Keys. If you do not know the fully qualified names of the fields in your PDF form, you can specify an empty JSON_OBJECT() for the mapping and the response will contain a list of available fields in the pdfFieldInfo property (see below).

BEGIN DECLARE myTemplatePdf VARCHAR(512); DECLARE myRequestBody JSON; -- get the PDF form from your database SELECT MyDocumentField INTO myTemplatePdf FROM MyTable WHERE ID = 'TAX_W2'; -- map fields and generate PDF FOR employee IN (SELECT SSN, First_Name, Last_Name FROM W2Data WHERE W2Data_ID = 12345) DO SET myRequestBody = JSON_OBJECT( 'sourcePdf', myTemplatePdf, 'outputFilename', 'Filled_TAX_W2.pdf', 'fieldValues', JSON_OBJECT( 'Emp_SSN', employee.SSN, -- Emp_SSN should be the fully qualified PDF field name 'Emp_First', employee.First_Name, 'Emp_Last', employee.Last_Name ) ); CALL parasql_http( 'POST', '', myRequestBody, 'MyCallback', -- name of your callback procedure NULL, NULL ); END FOR; END

Callback Procedure - Save the Output PDF

Your callback procedure must take the following parameters:
respCode INTEGER, respBody JSON, respHeaders JSON, callbackData JSON

BEGIN INSERT INTO PDF_Result (PDF_Result_ID, Document) VALUES (parasql_next_val('PDF_Result'), JSON_VALUE(respBody, '$.data.outputPdf')); END

API Specification


POST { "sourcePdf": myDocumentField, "outputFilename": "MyFilledForm.pdf", "fieldValues": { "myFullyQualifiedFieldName1":"value1", "myFullyQualifiedFieldName2":"value2" }, "flattenFields": "NONE", "ignoreMissingFields": true }


{ "status": "OK", "errorMessage": "", "errorCode": "", "data": { "outputPdf": "MyFilledW2TaxForm.pdf;12048;1598992709098;database/files/a655f610-febd-4f6a-b11d-6bcd696f5466.pdf", "pdfFieldInfo": [ { "fullyQualifiedName": "topmostSubform[0].Copy1[0].BoxA_ReadOrder[0].f2_01[0]", "isRequired": "false", "isReadOnly": "false", "type": "Tx" }, { "fullyQualifiedName": "topmostSubform[0].Copy1[0].Col_Left[0].f2_02[0]", "isRequired": "false", "isReadOnly": "false", "type": "Tx" } ] } }