Ask AI
Skip to main content

Create pdf from docx

Function: Create PDF from DOCX

This action allows you to generate a PDF document from an existing DOCX template in your media library. You can populate this template with dynamic data, such as customer names, invoice details, or report figures, to create personalized and up-to-date PDF files. The newly created PDF will be saved in your application's media library.

Input

  • Template (STRING, Required): The unique identifier (ID) or name of the DOCX template file from your media library that you want to use as the basis for your PDF.
  • Data (OBJECT, Required): A collection of key-value pairs (like a list of properties) that will be used to replace placeholders within your DOCX template. For example, if your template has a placeholder \{\{customerName\}\}, you would provide \{"customerName": "Acme Corp"\} in this data object.
  • Media name (STRING, Required): The desired name for the new PDF file that will be created and stored in your media library. This name should be unique and descriptive (e.g., "Invoice_CustomerX_2023.pdf").

Output

The action generates a new PDF file and stores it in your media library. The unique identifier (ID) of this newly created PDF is made available for use in subsequent steps.

  • Media ID (STRING): This is the unique ID of the PDF file created by this action. You will typically specify a variable name (e.g., myPdfFileId) where this ID will be stored, allowing you to reference the PDF in other actions (e.g., to attach it to an email or link to it).

Execution Flow

Real-Life Examples

Example 1: Generating a Customer Invoice

Imagine you have a DOCX template for invoices. When a customer's order is completed, you want to automatically generate a PDF invoice.

  • Inputs:
    • Template: "InvoiceTemplate_Standard.docx"
    • Data: \{"customerName": "Acme Corp", "invoiceNumber": "INV-2023-001", "totalAmount": "1500.00", "items": [\{"description": "Service A", "quantity": 1, "price": "1000.00"\}, \{"description": "Service B", "quantity": 1, "price": "500.00"\}]\}
    • Media name: "Invoice_AcmeCorp_INV-2023-001.pdf"
  • Output Variable Name for Media ID: invoicePdfId
  • Result: A new PDF file named "Invoice_AcmeCorp_INV-2023-001.pdf" is created in your media library, populated with the provided customer and invoice details. Its unique ID (e.g., "media_12345") is stored in the invoicePdfId variable, which can then be used to attach the invoice to an email.

Example 2: Creating a Personalized Event Ticket

For an upcoming event, you want to send personalized PDF tickets to each registered attendee.

  • Inputs:
    • Template: "EventTicketTemplate.docx"
    • Data: \{"attendeeName": "Jane Doe", "eventName": "Annual Tech Summit", "ticketType": "VIP", "seatNumber": "A12"\}
    • Media name: "Ticket_JaneDoe_TechSummit.pdf"
  • Output Variable Name for Media ID: eventTicketId
  • Result: A personalized PDF ticket named "Ticket_JaneDoe_TechSummit.pdf" is generated, showing Jane Doe's details for the Annual Tech Summit. This PDF is saved in the media library, and its unique ID (e.g., "media_67890") is stored in the eventTicketId variable, ready to be included in a confirmation email.

Example 3: Producing a Monthly Sales Report

At the end of each month, you need to generate a PDF report summarizing sales performance.

  • Inputs:
    • Template: "MonthlySalesReportTemplate.docx"
    • Data: \{"month": "October", "year": "2023", "totalSales": "500000", "topProduct": "Product X", "regionalSales": \{"North": "200000", "South": "150000", "East": "100000", "West": "50000"\}\}
    • Media name: "Sales_Report_October_2023.pdf"
  • Output Variable Name for Media ID: salesReportId
  • Result: A PDF sales report named "Sales_Report_October_2023.pdf" is generated, populated with the latest sales figures for October 2023, and stored in the media library. The report's unique ID (e.g., "media_11223") is stored in the salesReportId variable, making it available for archiving or distribution to stakeholders.