Modern Document Generation in Oracle APEX: Integration with OCI Document Generator

In today's fast-paced digital landscape, enterprise applications must be able to generate documents quickly, accurately, and automatically. Whether it's invoices, reports, contracts, or certificates, the demand for efficient document generation is growing across all industries. Oracle APEX (Application Express), a low-code development platform, has become a powerful solution for building scalable and secure web applications.

One of the standout capabilities of Oracle APEX, especially when combined with Oracle Cloud Infrastructure (OCI), is its ability to generate high-quality, dynamic PDF documents. This article explores how Oracle APEX integrates with OCI's Document Generator to streamline document creation, reduce complexity, and enhance user experience.

Oracle Cloud Infrastructure (OCI) Document Generator function continues to push the boundaries of report generation. With the recent updates (Oracle APEX 24.2), it now supports MS Excel templates, unlocking a broader range of possibilities for seamless report generation.You can create Templates using both MS Word and MS Excel and generate PDF, Excel, and Word documents.

 

1. Oracle APEX and the Need for Seamless Document Output

Oracle APEX has long provided tools for building data-driven applications with minimal effort. Yet, traditional document generation approaches; using third-party tools or manually coded integrations; can be slow, error-prone, and difficult to maintain.

The need for seamless, scalable, and cloud-native document output is especially critical for:

  • Generating invoices based on dynamic form inputs.
     
  • Producing detailed analytical reports from data queries.
     
  • Creating legal or contractual documents using predefined templates.
     

With the introduction of the OCI Document Generator, Oracle delivers a fully managed solution that integrates natively with APEX. Developers can now use serverless cloud functions to produce PDF documents based on APEX data, all within a secure and reliable environment.

2. Leveraging OCI Document Generator: APEX + Cloud Synergy

At the heart of this integration lies the OCI Document Generator, a serverless function running in Oracle Cloud. By using this generator, Oracle APEX applications can securely call an API that produces and returns PDF documents formatted with precision.

Here’s why this synergy is so powerful:

Easy Template Management

Templates (in DOCX format) can be created in Microsoft Word and uploaded to Object Storage. These templates are then populated using JSON payloads sent from APEX.

Simple API Invocation

APEX can trigger the function via a simple PL/SQL web request, sending the data and receiving a binary PDF in response, ready for download or preview.

Fully Managed & Scalable

The serverless nature of OCI Functions means no infrastructure management. The system scales with demand, and you only pay for what you use.

3. Real-World Use Cases: What You Can Build

Integrating Oracle APEX with OCI Document Generator opens the door to a variety of real-world applications that streamline operations and reduce manual work. Here are just a few examples of how businesses can benefit from this powerful combination:

Invoice and Billing Systems

Users input transaction details, products, prices, customer data, and instantly receive a professionally formatted invoice in PDF. With APEX and the document generator, this process becomes automatic, reliable, and visually consistent across all records.

Certificate and Report Issuance

Educational institutions or training platforms can use Oracle APEX to issue personalized certificates in bulk. Simply upload a DOCX template, and APEX can populate it with student names, dates, course info, and more.

Legal and HR Document Automation

Contracts, NDAs, onboarding forms; any document requiring templated structure and dynamic content can be generated in seconds with OCI and APEX. This not only saves time but also reduces legal risks by standardizing document output.

Compliance and Audit Reporting

In industries like finance and healthcare, generating on-demand reports for compliance is a necessity. APEX applications can query the latest data and produce formal reports in PDF, signed and ready for archiving or submission.

4. Step-by-Step Guide: Full Integration of OCI Document Generator with Oracle APEX

Integrating the OCI Document Generator Function with Oracle APEX has become significantly more streamlined, thanks to improvements in Oracle Cloud Infrastructure. Below is a detailed walkthrough based on the official Oracle APEX blog post, ensuring that each configuration step is clear for new developers and IT admins alike.

4.1. Prerequisites

Before starting, ensure the following:

  • An Oracle Autonomous Database: You can use an Autonomous Data Warehouse, Autonomous Transaction Processing, or Autonomous JSON Database.
     
  • An APEX instance: Your instance must not be hosted on APEX Application Development (APEX Service), as it lacks SQLNet support.
     
  • OCI Console access: You need the necessary permissions to configure APEX instances and deploy pre-built functions.
     

4.2. Step 1: Create a Document Generator Function in OCI

  1. In the OCI Console, go to the Navigation Menu → Developer Services → Pre-Built Functions.
     
  2. Select the Document Generator from the list.
     
  3. Click Create Function.
     
  4. Provide the required details:Function name  → Pre-Built Function Application (or create a new one)
     

Click Create.

Tip: For production environments, consider enabling Provisioned Concurrency to eliminate "cold starts" and ensure rapid document generation on first request.

4.3. Step 2: Create a Secure Connection to the Autonomous Database

  1. In the OCI Console, go to Developer Services → Database Tools → Connections.
     
  2. Click Create Connection, choose your Compartment, and provide a name.
     
  3. Use Select Database to pick your Autonomous Database instance.
     
  4. Provide user credentials. If needed, configure proxy authentication and network options like TLS or mTLS.
     
  5. Choose one of the following for wallet setup: Upload wallet manually (e.g., cwallet.sso) or Auto-login wallet (regional or instance-based) based on your setup
    * Security Tip: Use OCI Vault for storing your credentials and enable Private Endpoints if required by your database’s VCN.

Click Validate to ensure the connection is successful.

 

4.4. Step 3: Configure the Document Generator in Your APEX Instance

  1. In the OCI Console, go to Developer Services → APEX Instances.
     
  2. Select your target APEX Instance.
     
  3. Click Actions → Configure Document Generator.
     
  4. In the wizard: Choose the Compartment → Select the Database Connection, Document Generator Function, and Object Storage Bucket where your templates are stored.Provide a name for the IAM Policy to be created.Optionally change the Policy Compartment
     
  5. Click Configure.
     

If configuration is successful, a Done label will appear. Errors will be flagged with detailed messages.

4.5. Step 4: Validate the Integration from APEX

  1. Log in to your APEX Instance as an Administrator.
     
  2. Navigate to Instance Settings → Report Printing tab.
     
  3. Confirm that: The Print Server is set to Oracle Document Generator → All connection details are correctly populated.
     

This confirms that your APEX environment is now equipped to use the OCI Document Generator for pixel-perfect PDF document creation using Microsoft Word templates.

5. In-App Printing Configuration in Oracle APEX (Layouts, Queries, Actions, APIs)

Once the Document Generator Function is successfully configured as a remote print server in Oracle APEX, the next essential step is to enable printing capabilities within your APEX applications. This section walks through how to set up DOCX templates, define report queries, integrate layouts with reports, and leverage new declarative and programmatic features introduced in APEX 24.1.

5.1. Creating and Uploading a Report Layout

Oracle APEX allows developers to upload Microsoft Word (.docx) templates that define the structure and formatting of the final PDF document. These templates may include headers, footers, loops, images, and placeholders.

Steps to Create and Upload a Layout:

  1. Design your template in Microsoft Word, using placeholders like ${field_name}.
     
  2. If your report expects multiple records, define a loop structure (e.g., employees).
     
  3. In APEX: Navigate to Shared Components -> Report Layouts. Click Create and upload your .docx fileSpecify the Layout Name and Loop Name to match the template
     

Example:
If your layout uses ${employees.name} and ${employees.position}, your Loop Name should be employees.

5.2. Defining a Report Query (Classic or REST)

A report layout requires a data source to populate the fields defined in the template. APEX supports various query types to retrieve data dynamically.

Available data sources:

  • Standard SQL queries
     
  • SQL with bind variables
     
  • REST Data Sources
     

In APEX:

  1. Go to Shared Components → Report Queries
     
  2. Click Create and define:
     
    • Query Name
       
    • Data Source (SQL or REST)
       
    • Loop Name (must match the one used in the layout)

5.3. Using the Report Layout in a Classic Report

One intuitive way to enable PDF generation for users is by embedding layouts into Classic Reports.

Steps:

  1. Create a Classic Report region using the desired SQL query.
     
  2. Under the Attributes tab: Enable Printing → In the Printing section: Set Format to PDF Select the corresponding layout under Output Layout
     
  3. When the user clicks "Print", the configured template and query will be executed to generate a PDF document.

5.4. Using Declarative Print Report Page Processes

APEX 24.1 introduces a new Page Process Type called Print Report, which enables developers to print report queries declaratively without writing any code.

How to configure it:

  1. In the Page Designer tree, right-click Before Header → Create Process
     
  2. In the Identification section: Set the Type to Print Report
     
  3. Under Settings: Select the desired Report Query → Set the File Name (e.g., employee_report.pdf)Choose how to render the output: Download, Preview, or Inline

5.5. Printing via Dynamic Actions (e.g., from a Button)

Another modern UX feature in APEX 24.1 is the ability to trigger a print action from a Dynamic Action tied to any button.

Steps:

  1. Create a button (e.g., “Download PDF”).
     
  2. In the rendering tree, right-click the button → Create Dynamic Action
     
  3. For the True Action: Choose Action = Print Report → Configure: Report Query → File Name → View File As option
     

This approach provides a cleaner, more interactive experience for end users.

5.6. Advanced Integration with APEX_PRINT and APEX_HTTP APIs

For highly customized printing needs, Oracle APEX 24.1 offers robust PL/SQL APIs for full control over templates and data.

APEX_PRINT API

  • UPLOAD_TEMPLATE: Uploads a DOCX template to OCI Object Storage
     
  • GENERATE_DOCUMENT: Creates a PDF from the provided JSON data and template
     
  • REMOVE_TEMPLATE: Deletes a template from Object Storage
     

APEX_HTTP API

  • Enables file download to the client from a BLOB or CLOB source

Sample code:

6. Performance, Security and Cost-Effectiveness

One of the key advantages of using Oracle APEX with OCI Document Generator is the optimized performance and scalability it offers for enterprise workloads. Let’s break down why this solution is production-ready:

High Performance

The use of serverless OCI Functions ensures that document generation is fast, lightweight, and capable of handling thousands of concurrent requests with minimal latency.

Security-First Architecture

  • IAM Roles & Policies: Access to Object Storage and Functions is tightly controlled using Oracle Identity and Access Management (IAM).
     
  • Audit Logging: Every request and function execution can be logged and audited to ensure compliance.
     
  • Secure Templates: Uploaded templates are stored in OCI with full encryption at rest.
     

Cost-Effective Usage Model

Since the document generator runs as a serverless function, you only pay for the compute time used during each execution. This model is particularly attractive for businesses with fluctuating document generation needs.

Additionally, by centralizing your logic in APEX and OCI, you reduce maintenance costs and eliminate the need for third-party PDF tools or complex integration platforms.

Why This Matters for Modern Enterprises

As businesses become more data-driven and customer expectations for responsiveness continue to rise, document generation must evolve from a manual, slow process to a seamless, automated solution. Oracle APEX, when combined with the OCI Document Generator, provides exactly that; an enterprise-ready, scalable, and low-maintenance way to produce high-quality documents on demand.

From invoices and certificates to compliance reports and contracts, organizations can now build secure, customizable, and efficient document generation workflows directly into their APEX applications. This not only boosts productivity but also enhances the professional image of the business through consistent branding and fast response times.

With minimal setup and maximum impact, Oracle APEX with OCI Document Generator is the modern solution your organization has been waiting for.

 

7. Reference

  1. 3 Easy Steps to Integrate OCI Document Generator Function with Oracle APEX on Autonomous Database - Oracle Blogs (blogs.oracle.com)
  2. Enhancing Document Generation with OCI and Oracle APEX 24.2 - Oracle Blogs (blogs.oracle.com)
  3. Seamless PDF Generation with Oracle APEX and OCI Document Generator - Oracle Blogs (blogs.oracle.com)
  4. Document Generator Function (blogs.oracle.com)

 

July, 18th 2025.

WAYKITECH “We Make Technology Work for You”

“We Make Technology Work For You”