Document Generator in APEX: An alternative to AOP?

Michael Pickering Apr 18, 2024 11:21:05 AM

Earlier this year, Oracle announced the introduction of the Document Generator pre-built function in Oracle Cloud Infrastructure (OCI). They have also created a sample application available in the gallery, which showcases how to utilise DG within an APEX application. The obvious question that immediately springs to mind for anyone with experience with APEX and dynamically generated documents is: how does this compare to APEX Office Print (AOP)? In this blog, I’m going to review Document Generator, with a specific eye on its use within APEX, using the Sample Application as the jumping-off point. I will also consider how the approach compares with AOP.

What is Document Generator?

The Document Generator function is part of the catalogue of pre-built functions available in OCI. Unlike AOP, this function is not tied to or specifically geared towards APEX. Instead, its intended use is across the spectrum of Oracle applications and services hosted on OCI.

Document Generator in APEX: An alternative to AOP?

(Link)

The Document Generator function utilises templates and JSON data to generate PDFs. As it is an OCI offering, the configuration is therefore largely done within the OCI console. It utilises another important element of OCI, the Object Storage bucket, to both host the templates (in MS Office format) and provide the target for the PDF output.

How does it work?

To use Document Generator, you must first configure it within the OCI Console. It is found in Developer Services -> Functions -> Pre-built Functions.

Document Generator in APEX: An alternative to AOP?

When initialising, you must create a compartment and an application to assign the new function instance. (Document Generator Function).

You then need to create an object storage bucket to host the templates and output and set up the necessary groups and policies to allow the correct access.

Reviewing the Sample APEX app

One thing that will be apparent already is that Document Generator is very much tied to OCI. This is something that the Sample App makes clear from the outset. Indeed, if you try to install it anywhere other than an OCI APEX service/ATP, you are told that the functionality won’t work:

Document Generator in APEX: An alternative to AOP?

This emphasises the point that unless your application estate is on OCI, then Document Generator is not going to be an option. If your APEX app isn’t on the cloud, it doesn’t necessarily mean you can’t use the function via an API, but you still need to have a paid OCI account in some form. This limits consideration of this as an alternative to AOP, which can be configured in various ways and run on both On-Prem and cloud solutions.

Assuming you are on OCI, helpfully, the APEX sample application contains steps on how to configure the function and set it up to work with APEX.

Document Generator in APEX: An alternative to AOP?

The heavy lifting within the APEX application is done via a process plugin (OCI Document Generator – Print Document), which requires some setting up, basically to allow the plugin to interface with the DG API and utilise the object storage components that you’ve set up correctly:

Document Generator in APEX: An alternative to AOP?

Document Generator in APEX: An alternative to AOP?

One thing that will be noticeable to AOP users is how similar Document Generator is in terms of template setup and input data. In the templates provided in the sample app, you can see how the data tags within the template are pretty much identical to those within AOP – a good example being the use of # and / to open and close tabular data loops.

Document Generator in APEX: An alternative to AOP?The JSON data query is also very similar to AOP, down to the use of ‘data’ as the parent-level object.

Document Generator in APEX: An alternative to AOP?

How does Document Generator compare to AOP?

In its current form, from a purely APEX perspective, at least, there’s nothing that Document Generator can do that AOP can’t. Its potential/attraction lies in the fact that it is not just geared towards APEX and can be used across multiple Oracle services, making it an attractive proposition for organisations that have a diversity of Oracle solutions but want a homogenous way of producing dynamic PDF reports/documents.

AOP was designed specifically for APEX, which is a potential limitation in the scenario described above. But, it is also a huge advantage in terms of its usability within an APEX development space. The solution is mature, and there is a wealth of supporting documentation available to developers. There are elements of AOP functionality that DG doesn’t seem to cover (yet, at least). One example of the advantage of AOP in APEX is the ability to generate output directly from, say, an interactive grid or report.

Document Generator currently produces only PDF documents, whereas AOP allows you to generate a variety of additional formats, such as Word and Excel.

As mentioned above, the syntax used in using Document Generator is very similar to AOP, so developers familiar with AOP should have no problem switching over if required.

Conclusion

Document Generator is certainly a potential alternative to AOP, and that potential may well grow in the future. At this point, however, in many cases, AOP would probably still be the first choice.

If you are looking at PDF generation from APEX, have no legacy solution to consider and are already invested in OCI, it is worth considering the Document Generator function, especially if your requirements are relatively fixed and unlikely to branch out into complex document creation. However, AOP is still a serious consideration given the maturity of the solution, the ease of use with APEX and the sheer volume of excellent documentation available.

For more information, check out our APEX services, and if you liked this blog, check out our other APEX blogs here.

Remember to follow us on LinkedIn. We publish insight blogs on the latest technology developments every week.

Subscribe to Oracle APEX Insights if you want to stay tuned for more APEX updates.