5 min readUpdated Mar 2, 2026

Documentation for writePdf Logic

Overview

The writePdf logic component in Vantage is designed for converting tabular data into a formatted PDF document, or for uploading existing PDF binary content to OneDrive. This functionality is particularly valuable for users needing to generate reports or export data in a visually appealing format for sharing or archival purposes.

Purpose

The primary purpose of writePdf is to:

Expected Input Data

writePdf expects one of the following types of input:

If the data provided is neither of these formats, the operation will fail.

Settings

1. fileName

2. subfolder

3. mode

4. title

How It Works

  1. Input Handling: writePdf retrieves the input data. It can handle nested data structures and unwrap them to obtain an array of objects.
  2. Configuration: The file name, optional subfolder, mode (overwrite or create), and title for the document are retrieved from the configuration.
  3. Timestamp Generation: A timestamp is generated in ISO format to append to the filename to ensure that each file is uniquely named.
  4. Integration with OneDrive:
    • The function ensures that the OneDrive integration is configured properly and retrieves the necessary clientId.
    • It checks for the existence of specified subfolders and creates them if needed.
  5. PDF Generation:
    • If no valid data is provided, an error is returned.
    • If data is provided, it checks the format (Buffer, string, or array) and proceeds to generate a PDF using the generatePdfFromData function, which uses the pdfkit library.
  6. File Upload: Finally, the generated or provided PDF is uploaded to OneDrive, and relevant metadata is returned.

Integration with AI Features

The current implementation does not specify any direct integration with AI functionalities. However, users can potentially enhance their data visualizations and report insights using various AI-driven analytics provided by Vantage.

Billing Impact

Using the writePdf logic may incur costs associated with:

Use Cases & Examples

Use Case 1: Business Reporting

A marketing team needs to generate monthly performance reports in PDF format to share with stakeholders. By using writePdf, they can automate the process of generating these reports from their analytics data stored in Vantage.

Use Case 2: Data Export for Compliance

A finance department requires exporting transaction data into PDF reports for compliance audits. writePdf allows them to pull the relevant data and format it neatly for submission.

Use Case 3: Dynamic PDF Generation

An application that allows users to create custom reports can utilize writePdf to let users generate on-demand PDFs from any customizable data inputs through the application interface.

Detailed Example Configuration

For a marketing team generating a report:

json
{
    "inputs": {
        "input1": [
            {"date": "2023-10-01", "campaign": "Campaign A", "impressions": 1000, "clicks": 100},
            {"date": "2023-10-02", "campaign": "Campaign B", "impressions": 1500, "clicks": 150}
        ]
    },
    "config": {
        "fileName": "Marketing_Report",
        "subfolder": "Monthly Reports",
        "mode": "create",
        "title": "October 2023 Marketing Performance Overview"
    },
    "context": {
        "clientId": "your-client-id"
    }
}

In this example, the marketing team defines the input dataset as an array of campaign performance metrics. They choose to save the file in the "Monthly Reports" subfolder of OneDrive, create a unique filename for each report based on the month's performance, and set a meaningful title for clarity.