Generate PDF
Use this function to generate PDF files based on a predefined template.
The generated PDFs are uploaded to S3 and returned as file IDs.
Usage
const pdfGenerated = await generatePdf(payload);Payload Structure
The payload object must follow this structure:
{
templateID: "id-of-the-template", // Required
tableName: "name-of-table", // Optional
columnName: "name-of-the-column", // Optional
templateData: {
row: {
columnName1: "columnValue1",
columnName2: "columnValue2",
columnName3: "columnValue3"
}
}
}Parameter Details
templateID (Required)
Unique ID of the predefined PDF template configured in the system.
tableName (Optional)
Name of the associated table (used for reference or file naming logic).
columnName (Optional)
Specific column reference, if required in your implementation.
templateData (Required)
Dynamic data injected into the PDF template.
templateData: {
row: {
// key-value pairs used inside the template
}
}Return Value
Returns a list of generated PDF filenames uploaded to S3.
Sample Output
{
fileIds: [
"invoice1.pdf",
"invoice2.pdf"
]
}Example Implementation
async function customizeERP(userData, apiOperations) {
const { generatePdf } = apiOperations;
// Build PDF payload
const pdfPayload = {
// Replace with your actual template ID
templateID: "your-template-id-here",
// Optional, if needed for reference
tableName: "your-table-name",
templateData: {
// Dynamic data passed to the template
row: userData
}
};
// Generate PDF
const pdfResult = await generatePdf(pdfPayload);
return {
result: pdfResult,
popupMsg: {
type: "message",
message: "PDF generated successfully."
}
};
}