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.
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.
Cost-effectiveness
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.
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.
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
On OCI, open the navigation menu and select Pre-Built Functions in Developer Services.
Select Document Generator.
Click the Create Function button. If a suitable application doesn't already exist in the current compartment, click Create new application.
Tip: when you are using Document Generator in production, you can enable provisioned concurrency to reduce initial provisioning time and ensure hot starts.
Click the Create button to finish the wizard and you can see the function is now deployed in the application.
Create an Object Storage Bucket
Open the navigation menu and select Buckets from Storage.
Create a new bucket if needed and provide a name.
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.
The matching rule is defined as:
resource.id = '<db_ocid>'
Next, we create a new Policy for this Dynamic Group. Open the navigation menu and select Policies from Identity & Security.
Create the following policy.
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.
Execute the following code as the ADMIN user.
begin
DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL();
DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL(username => '<WORKSPACE_SCHEMA>');
end;
/
grant DWROLE to <WORKSPACE_SCHEMA>;
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:
- Region Name: The OCI region of the Object Storage Bucket and Document Generator function.
- Document Generator Function OCID: The OCID of the function in the OCI application.
- Bucket Namespace: The OCI namespace of the Object Storage Bucket.
- Bucket Name: The name of the Object Storage Bucket.
Now we have completed the prerequisites and are ready to use the app!
Source: oracle.com
0 comments:
Post a Comment