Announcing the Oracle APEX Sample Document Generator App!

March 5, 2024 | 6 minute read
Menno Hoogendijk
Principal Member of Technical Staff
Text Size 100%:

Recently, Oracle released the Document Generator Pre-built Function, A new function to generate PDF documents from a combination of JSON data and MS Word templates.

Today, we are releasing the Sample Document Generator App, which showcases the integration of the Document Generator in APEX. The app is now available in the APEX 23.2 Gallery.

Entry of the sample application in the gallery

This app includes examples to generate PDF documents using a custom plug-in, which invokes the Document Generator Function. Feel free to explore the plug-in code, look at MS Word templates stored in Static Application Files, and the JSON.


In order to create the Pre-Built Document Generator function, you need to have a paid account but the pricing is extremely cost-effective. With Oracle Cloud Functions, you only pay for the resources consumed during execution, eliminating the need for upfront infrastructure investment. You can learn more about functions and the pricing here.

Installation on Oracle Cloud is required

The sample app uses a plug-in, which leverages the Oracle Cloud Infrastructure SDK for PL/SQL, which makes it very easy to manage / invoke OCI resources. This SDK is only available on the Autonomous Database, which means the sample app requires an Autonomous Database. This does not mean you can’t use the Document Generator in another APEX instance. Timo Herwix published a great blogpost where he is using REST to invoke the function.

There are several prerequisites we must take care of before we can use the sample app to generate PDF documents. These steps are outlined below.

Configure the Document Generator Function

Below we follow the steps from the documentation.

On OCI, open the navigation menu and select Pre-Built Functions in Developer Services.

Navigation menu highlighting Pre-Built Functions

Select Document Generator

Pre-Built Functions page which highlights the Document Generator Function

Click the Create Function button. If a suitable application doesn't already exist in the current compartment, click Create new application.

Page to create a function, it highlights the create buttons.

Tip: when you are using Document Generator in production, you can enable provisioned concurrency to reduce initial provisioning time and ensure hot starts.

Section to enable provisioned concurrency

Click the Create button to finish the wizard and you can see the function is now deployed in the application.

Page showing active function after creation

Create an Object Storage Bucket

Open the navigation menu and select Buckets from Storage.

Navigation menu which highlights the Buckets link

Create a new bucket if needed and provide a name.

Page showing the Create Bucket wizard with highlights on the create buttons

The sample app will use this bucket later to store the MS Word templates and PDF documents.

Configure the Database

In the next steps we make sure the database has the rights to invoke the Document Generator function and manage objects in Object Storage Buckets.

We start by creating a Dynamic Group for the database.

Open the navigation menu and select Domains from Identity & Security. Select the identity domain you want to work in and click Dynamic Groups. Create a new Dynamic Group if needed by specifying a name, description, and a rule using the OCID of your Autonomous Database as resource ID. Remember the name because we will need it afterwards.

Wizard to create a dynamic group highlighting the important fields

The matching rule is defined as: = '<db_ocid>'

Next, we create a new Policy for this Dynamic Group. Open the navigation menu and select Policies from Identity & Security.

Navigation menu which highlights the Policies link

Create the following policy.

The Create Policy wizard which highlights the important fields

Allow dynamic-group <group_name> to manage objects in compartment <compartment_name>
Allow dynamic-group <group_name> to manage buckets in compartment <compartment_name>
Allow dynamic-group <group_name> to use functions-family in compartment <compartment_name>

As final step in OCI we have to execute the following statements as the ADMIN user in the Autonomous Database.

Go to the Automous Database and Click SQL under Database Actions.

Database actions dropdown menu which highlights the SQL entry

Execute the following code as the ADMIN user.

SQL worksheet in Database actions with the statements to execute



The resource principal is used to authenticate and access Oracle Cloud Infrastructure resources. The DWROLE enables you to use the OCI PL/SQL SDK.

Quickly Installing the Document Generator Sample App

Perform the following steps to install the app:

  1. Go to the App Gallery.
  2. Search for the Sample Document Generator app.
  3. Click install.
  4. Go to application and navigate to Shared Components > Component Settings
  5. Specify values for the empty attributes:
    1. Region Name: The OCI region of the Object Storage Bucket and Document Generator function.
    2. Document Generator Function OCID: The OCID of the function in the OCI application.
    3. Bucket Namespace: The OCI namespace of the Object Storage Bucket.
    4. Bucket Name: The name of the Object Storage Bucket.

Component Settings of the plug-in which highlights the attributes

Now we have completed the prerequisites and are ready to use the app!

The home page of the sample application

We hope you enjoy this app and learn how you can integrate with the Document Generator Pre-Built Function!

Menno Hoogendijk

Principal Member of Technical Staff

Principal member of technical staff for the Oracle APEX development team.

Previous Post

Leading Industry Analyst Views on Oracle Globally Distributed Autonomous Database

Youko Watari | 6 min read

Next Post

Autonomous Health Framework Version 24.2 Released

Gareth Chapman | 4 min read