Renduva

Renduva documentation

APEX plug-in

The APEX plug-ins make documents from an APEX page with no PL/SQL: you name a template, type your SQL queries, pick an output, and the user gets the file. They run on the renduva and renduva_apex packages of the PL/SQL package, so everything they do can also be done from PL/SQL.

The two plug-ins

Each plug-in file adds two plug-ins with the same settings:

Plug-in Type Internal name Use it for
Renduva - Generate Document Process COM.RENDUVA.GENERATE a button that submits the page, or a Before Header process on a page you link to
Renduva - Generate Document (Dynamic Action) Dynamic action COM.RENDUVA.GENERATE_DA making a document without submitting the page, e.g. a Preview button

There are two files, one per APEX version range. Both run the same renduva_apex code, so one database can serve applications on either:

File APEX
renduva_plugin_apex26.sql 26.1 and later
renduva_plugin_apex23.sql 23.2 to 25.x

The 26.1 file has a few more settings; see Differences between the two files. Both files are in the Oracle zip on the download page.

Set up

You need a running Renduva server and an API key (Install and run), and the packages installed in the application's parsing schema, with a network ACL for both that schema and the APEX schema (PL/SQL package: Install). For an https:// server, the database wallet APEX uses must trust its certificate.

Web Credential

The plug-ins never hold the API key themselves. Store it as a Web Credential in Workspace Utilities → Web Credentials:

Setting Value
Static ID e.g. RENDUVA
Authentication Type HTTP Header
Credential Name Authorization
Credential Secret Bearer rdv_...: the word Bearer, a space, and your API key
Valid for URLs your server, e.g. https://renduva.internal/

APEX keeps the key encrypted, sends it only to those URLs, and leaves it out of application exports.

Import

In Shared Components → Plug-ins → Import, import the file for your APEX version. Each application that makes documents needs its own import.

To upgrade, import the new file the same way. Your Component Settings, processes and dynamic actions are kept. After an APEX upgrade to 26.1, import the 26.1 file over the 23.2 one in the same way.

Component Settings

In Shared Components → Component Settings, set these for each of the two plug-ins (they are kept separately):

Setting Value
Server URL the server's address without /generate, e.g. https://renduva.internal
Web Credential the Static ID of the Web Credential, e.g. RENDUVA

First document in 10 minutes

This makes a PDF invoice from a button, with data from dual so it works in any schema.

1. Set up the Web Credential, import the plug-in file, and fill in the Component Settings of Renduva - Generate Document, as above.

2. Make the template. In Word, write:

Invoice {{invoice.invoice_no}}
{{invoice.customer}}, {{invoice.issued_on | date "DD Mon YYYY"}}

Below it, add a table with a header row (Description, Qty, Price) and one more row holding {{#items}}{{description}}, {{quantity}} and {{price | currency USD}}{{/items}}, one per cell. Under the table, write Total: {{sum items price | currency USD}}. Save it as invoice.docx.

3. Upload it in Shared Components → Static Application Files → Create File.

4. Add a page (a blank page, e.g. page 10) with a button DOWNLOAD whose action is Submit Page.

5. Add a process in the page's Processing, of type Renduva - Generate Document:

Setting Value
Template Source Static Application Files
Template invoice.docx
Queries Source Queries
Output PDF
File Name invoice.pdf
Server-side Condition When Button Pressed: DOWNLOAD

and in Queries:

-- query: invoice
select 'City of Example' customer, 'INV-1001' invoice_no, sysdate issued_on from dual

-- query: items
select 'Consulting' description, 2 quantity, 150 price from dual
union all
select 'Travel', 1, 80 from dual

6. Set the page's Reload on Submit to Always (page attributes, Advanced). With the default, Only for Success, APEX does not allow a download from a submit and shows an error.

7. Run the page and click Download. Without a license, every page carries the "Renduva Community" watermark.

From here, replace the queries with your own tables and use page items as bind variables, e.g. where i.id = :P10_INVOICE_ID.

Process settings

The settings appear in this order in Page Designer. Settings that do not apply to the choices above them are hidden.

Template

Setting Meaning
Template Source Where the template comes from; default Static Application Files. See below
Template For a static file, its full name with any folder, e.g. invoice.docx or templates/invoice.docx. For Renduva Server, the stored template's name, e.g. invoice for templates/invoice.docx on the server. Substitutions such as &P10_TEMPLATE. work
Template Query For SQL Query returning a BLOB: a query returning one row with one BLOB column, the template. Page items are bind variables
Template Source The template is Good for
Static Application Files a file in the app's Shared Components → Static Application Files templates that belong to one app: they are exported and deployed with it
Static Workspace Files a file in Workspace Utilities → Static Workspace Files one template shared by the workspace's apps
SQL Query returning a BLOB read by your query, e.g. select doc from my_templates where name = :P10_TEMPLATE templates kept in your own table, such as ones users upload
Renduva Server stored on the server, by name templates shared by every caller, managed in the admin UI

With the first three, the file is sent with each request (a typical template is 10 to 50 KB); for a server template only its name is sent. Processes made before Template Source existed keep using the server.

The template's type is read from the file itself: a Word, PowerPoint or Excel file by its contents, an HTML page by its first tag (<!doctype html> or <html>). Other text files go by the file name's extension (.md, .txt, .zpl); a text template from a query, which has no file name, is ZPL when it starts with ^ or ~ and plain text otherwise.

Data

Setting Meaning
Queries Source Queries (default), Report Query (26.1 file only) or PL/SQL Function Body returning CLOB. See Queries sources
Queries For Queries: any number of sections, each starting with a line such as -- query: name. See Queries
Report Query For Report Query: the name or Static ID of a Report Query in this application
PL/SQL Function Body For PL/SQL Function Body returning CLOB: code that returns queries or the data as JSON

Output

Setting Meaning
Output The file to make; default PDF. See the table below
File Name The downloaded file's name, e.g. invoice_&P10_INVOICE_ID..pdf; default document. plus the output type, e.g. document.pdf. For a PDF it is also the title the browser shows on its tab. Not for Direct to Printer
Locale Language and region for formats in tags, e.g. de-DE; default en-US
Show As Download (default) or Open in Browser. Not for Direct to Printer
Output From a template of type Tier
PDF any type except ZPL that of the template type (Word: every tier)
Word (DOCX) Word every tier
OpenDocument Text (ODT) Word Standard
HTML HTML or Markdown Standard (from Markdown: Professional)
Excel (XLSX), OpenDocument Spreadsheet (ODS) Excel Professional
Text (TXT) text (.txt) Professional
Markdown (MD) Markdown (.md) Professional
PowerPoint (PPTX), OpenDocument Presentation (ODP) PowerPoint Enterprise
Direct to Printer see Printing Professional
ZPL File ZPL label Professional
Label Image (PNG) ZPL label: a picture of the filled labels, to check them on screen Professional

See More template types and Labels and printing. The tiers are listed under License; a feature the license does not include fails with a message naming the tier it needs.

A process that sends a file ends the page request: processes and branches after it do not run.

PDF options

Shown only for PDF output. All need the Enterprise tier.

Setting Meaning
PDF/A Make a PDF/A-2b file, for archiving; default off. Cannot be combined with a password or attached PDFs
Password Item A page item holding the password needed to open the PDF (AES-256). An empty item means no password
Attach PDFs 23.2 file only: a query returning one BLOB column; each row's PDF is added after the document, in row order. Page items are bind variables

See PDF options for what the server does with them.

Page numbers and stamps

26.1 file only, for PDF output, in the Page Numbers and Stamps section (Professional tier or higher):

Setting Meaning
Page Numbers Text on every page, with {page} for the page number and {pages} for the page count, e.g. Page {page} of {pages}. The numbers run across the whole PDF, attached PDFs included. Empty: none
Page Number Position Bottom Center (default), Bottom Right, Bottom Left, Top Center, Top Right or Top Left; shown when Page Numbers has text
Stamp A word printed large, faint and diagonally across every page, such as COPY, DRAFT or CONFIDENTIAL. Empty: none

Substitutions such as &P10_STATUS. work in both texts. For other sizes, colors or pages (first page only, odd pages), call renduva.generate with p_stamps; see PDF output.

PDF permissions

26.1 file only, for PDF output, in the PDF Permissions section (Enterprise tier):

Setting Meaning
Owner Password Item A page item holding the owner password. When it has a value, readers may only do what Allowed Actions lists; the owner password lifts the restrictions. It must differ from the Password Item's value. Empty item: no restrictions
Allowed Actions Print; Copy Text and Images; Edit; Add Comments; Fill in Forms; Insert, Rotate or Delete Pages. Nothing ticked: readers may only read the PDF

For a dynamic action, add the password items to Items to Submit.

Attachments

The 26.1 file has an Attachments section instead of Attach PDFs, for PDF output (Enterprise tier):

Setting Meaning
Attachment Source None (default), Static Application Files, Static Workspace Files or SQL Query returning a BLOB
File Name(s) For static files: full file names, comma-separated, in order, e.g. terms.pdf, pdf/brochure.pdf. Substitutions such as &P10_TERMS. work
Attachment Query For a query: one BLOB column, one PDF per row, in row order. Page items are bind variables
Attachment Position After the Document (default) or Before the Document
Start Each on a Front Page For printing on both sides: a blank page is added where needed so the document and each attached PDF start on a front (odd) page (Professional tier or higher)

Attached files must be PDFs. A file name that does not exist is an error naming the file.

With the 23.2 file, a query can still attach static files:

select file_content from apex_application_static_files
 where application_id = :APP_ID and file_name in ('terms.pdf', 'brochure.pdf')
 order by file_name

(for Static Workspace Files, apex_workspace_static_files with workspace_id = :WORKSPACE_ID). A process moved from the 23.2 file to the 26.1 file keeps its Attach PDFs query, attached after the document; set Attachment Source to SQL Query returning a BLOB to see or change it.

Digital signature

26.1 file only, for PDF output, in the Digital Signature section (Enterprise tier). The admin first adds the certificate on the Renduva server (setting up a signer).

Setting Meaning
Signer The name of a signer on the server, e.g. finance. Empty: not signed. Substitutions such as &P10_SIGNER. work
Reason, Location Shown in the PDF reader's signature panel and in the box, e.g. Invoice &P10_INVOICE_NO. approved. Substitutions work
Show Signature No (Invisible) (default), Box on the First Page or Box on the Last Page: a box at the bottom right with the signer's name, the reason, the location and the date
Date Format, Time Zone With a box: how it shows the date, as a template date format such as DD/MM/YYYY HH24:MI (month names follow the Locale setting; empty: YYYY-MM-DD), and in which time zone, e.g. America/Bogota (empty: UTC)
Timestamp A trusted time from the server's timestamp server (its -tsa option), so the signature stays checkable after the certificate expires

The signature is the last change to the file, after attachments, page numbers and passwords. For other box positions or a certifying signature, use renduva.generate or the HTTP API.

PDF forms

26.1 file only, for PDF output, in the PDF Forms section (Enterprise tier):

Setting Meaning
Keep Word Fields Fillable A Word template's content controls become fillable PDF fields, named by each control's title
Lock Filled Fields Every form field becomes read-only, so the filled PDF cannot be changed in a reader. For fillable PDF templates and kept Word fields

A fillable PDF uploaded as the template (a Static File or a stored .pdf) is filled by field name; no setting is needed for that.

Printing

With Output = Direct to Printer, the process prints instead of downloading, and the page goes on with a success message such as Printed on warehouse. Professional tier.

Setting Meaning
Printer Name The name of a printer set up on the Renduva server (admin UI, Printers), or a substitution such as &P10_PRINTER.. The printer decides the type: a Word template prints as PDF on an office printer, a ZPL label template on a Zebra printer

See Labels and printing for setting up printers and what the printer statuses mean.

Dynamic action settings

The dynamic action has the same settings as the process, except:

Setting Meaning
Items to Submit Page items whose current values the queries use as bind variables, e.g. P10_INVOICE_ID, and the Password Item if there is one. They are sent without submitting the page
Show As Download (default; the page stays as it is), Open in This Tab or Open in New Tab
Attach PDFs Not in the 23.2 file. The 26.1 file has the same Attachments section as the process

It needs no Reload on Submit setting. While the document is made, a spinner shows; errors show on the page as usual. With Direct to Printer, the page shows the result as a success message.

The finished document waits in the user's APEX session (collection RENDUVA_DOCUMENTS) until the browser fetches it, once. A second fetch of the same document fails with the document is no longer available; generate it again.

Use the dynamic action's Wait for Result option when later actions should run only after the document is made.

Queries

The Queries field holds any number of sections. Each one starts with a line -- kind: name and its data goes into the document under that name. The process makes one document from all of them.

-- query: invoice
select c.name customer, i.invoice_no, i.issued_on, i.total
  from invoices i join customers c on c.id = i.customer_id
 where i.id = :P10_INVOICE_ID

-- query: items
select description, quantity, price
  from invoice_lines
 where invoice_id = :P10_INVOICE_ID
 order by line_no

-- query: payments
select paid_on, amount from payments where invoice_id = :P10_INVOICE_ID order by paid_on

Each query's rows become a list under its name, one field per column. In the template:

  • {{#items}}{{description}} {{price}}{{/items}} repeats a query's rows, and {{^payments}}No payments yet.{{/payments}} shows when a query returns none.
  • {{invoice.customer}} reads a column of a query that returns one row, anywhere in the document (see Fields).
  • Totals work over any query: {{sum items price | currency EUR}}.

How columns become data:

Column Becomes
name the column name in lower case: INVOICE_NO is invoice_no. Use aliases that are valid field names (letters, digits, _)
NUMBER a number
DATE, TIMESTAMP (any kind) text YYYY-MM-DDTHH24:MI:SS, so | date "DD Mon YYYY" formats it; fractions of a second and time zones are dropped
CLOB, VARCHAR2 and others text
BLOB a picture, for a picture tag such as {{logo}} (see Images; Standard tier)

Rules:

  • Page items are bind variables (:P10_INVOICE_ID). A trailing ; is allowed.
  • Names start with a letter or _, followed by letters, digits or _. They are made lower case, and must be different from each other.
  • Nothing but blank lines may come before the first section line, and nothing may follow the name on a section line (except for -- graphql:).
  • A query that fails stops the process with its name: query items: ORA-00942: table or view does not exist.
  • The field holds up to 4,000 characters (an APEX limit). For longer queries, use a Report Query or a PL/SQL Function Body.

Other kinds of data

Besides -- query:, a section can read data from somewhere else:

Section Below it Becomes Tier
-- query: name a SQL query a list: one entry per row, one field per column every tier
-- json: name a query whose first column is JSON (a JSON column, json_object(...), or a JSON duality view: select data from orders_dv where ...) a list: one entry per JSON object; a JSON array adds each of its elements Standard
-- xml: name a query whose first column is an XML document (text, or xmlserialize(document x as clob)) a list: one entry per document. Elements become fields, repeated elements a list, attributes fields too; the root element itself is left out Standard
-- region: static_id nothing a list: the rows of the region with that Static ID on this page (or page 0), with the user's current filters and sort in an Interactive Report or Grid Professional
-- rest: static_id its parameters, one per line: name = value or name = :P10_ITEM a list: the rows of the REST Data Source (Shared Components) with that Static ID, with its own credentials Professional
-- graphql: name url=https://... credential=STATIC_ID a GraphQL query the answer's data object (not a list). Each $variable the query declares takes the page item of that name; credential (optional) is a Web Credential. GraphQL errors stop the process with their message Professional

In XML, names lose any namespace prefix, and - and . in names become _. Without the tier, the server refuses the document with a message naming the tier (see License).

-- rest: and -- graphql: reach other servers from the database, so they need a network ACL for that host (and the database wallet for HTTPS), like the Renduva server itself.

Nested lists

-- query: invoices
select invoice_id, invoice_no, customer from invoices where batch_id = :P10_BATCH

-- query: lines
select l.invoice_id, l.description, l.price
  from invoice_lines l join invoices i on i.invoice_id = l.invoice_id
 where i.batch_id = :P10_BATCH

With {{#invoices}}...{{#lines}}...{{/lines}}...{{/invoices}}, each invoice shows only its own lines: a list nested in another list in the template keeps the entries whose fields with the same name match (here invoice_id). See Nested lists.

Queries sources

Queries Source The data comes from Good for Tier
Queries the Queries field most documents every tier for -- query:; see above for the other kinds
Report Query a Report Query in Shared Components → Report Queries, by name or Static ID: each of its sources, in order, becomes a list named by its Data Loop Name long queries, with APEX's own editor for adding sources (26.1 file only) Standard
PL/SQL Function Body returning CLOB your code, which returns either queries in the -- query: name form or the data itself as a JSON object queries kept in a package (return invoice_pkg.queries;), or data from anywhere else: a REST source through apex_exec, a JSON duality view, your own API Standard
  • A Report Query source must be a SQL Query, with a Data Loop Name (or, without one, a source name) of letters, digits and _. Page items are bind variables there too. For a source of another kind, return its data as JSON from a PL/SQL Function Body instead.
  • A function that returns text starting with { is taken as the data: one JSON object whose lists the template repeats, e.g. {"invoice": [{"customer": "..."}], "items": [...]}, used exactly as returned. Anything else is read as queries, up to 32,767 characters.
  • Processes made before Queries Source existed keep using the Queries field.

For example, data built in PL/SQL:

declare
  l_data json_object_t := json_object_t();
begin
  l_data.put('invoice', json_array_t(my_api.invoice_json(:P10_INVOICE_ID)));
  return l_data.to_clob;
end;

Templates, printers and signers on the server

To see which templates, printers and signers the server has, run in SQL Workshop, with your application's ID:

select * from table(renduva_apex.templates(100));
select * from table(renduva_apex.printers(100));
select * from table(renduva_apex.signers(100));   -- name, subject, issuer, valid_until, self_signed

They use the Server URL and Web Credential in the Component Settings of the process plug-in. Inside the application the ID can be left out, so the same functions make Lists of Values, e.g. a page item P10_PRINTER with select name d, name r from table(renduva_apex.printers) and the process's Printer Name set to &P10_PRINTER., or a signer picked the same way with select name d, name r from table(renduva_apex.signers).

Differences between the two files

26.1 file 23.2 file
APEX 26.1 and later 23.2 to 25.x
Queries Source Queries, Report Query, PL/SQL Function Body Queries, PL/SQL Function Body
Attached PDFs, process Attachments section: static files or a query, before or after Attach PDFs: a query, after the document
Attached PDFs, dynamic action Attachments section, as the process none
Page numbers, stamp, PDF permissions, signature, forms, duplex Page Numbers and Stamps, PDF Permissions, Digital Signature and PDF Forms sections none (use renduva.generate from PL/SQL)

APEX before 26.1 allows a plug-in only 15 settings, which is why the 23.2 file has fewer. Everything else is the same in both.

Errors

A failure stops the process and shows on the page as an APEX error. Errors from the server carry its HTTP status and the request ID:

ORA-20100: renduva: HTTP 401: missing or invalid API key (request 5aaff834a30f715c)

The request ID finds the request in the server's log (admin UI, Logs); give it to support (see Logs and support). Errors found in the database name the setting or section, e.g. query items: ORA-00942: table or view does not exist. The dynamic action shows the same messages without the ORA-20100: renduva: prefix.

Common setup mistakes

Symptom Cause
An APEX error about downloads after clicking the button The page's Reload on Submit is not Always
ORA-24247: network access denied by access control list (ACL) The ACL is missing for the parsing schema or the APEX schema (APEX_ plus the release); see Install
HTTP 401: missing or invalid API key The Credential Secret lacks Bearer before the key, the key was revoked, or Valid for URLs does not cover the Server URL
A certificate error with an https:// server The APEX wallet does not trust the server's certificate
no Static Application File invoice.docx The Template must be the full file name, with any folder, e.g. templates/invoice.docx
application 100 has no Renduva server The Component Settings of Renduva - Generate Document are empty
The dynamic action fails but the process works Each plug-in has its own Component Settings: fill in the dynamic action's too
Queries: start each query with a line -- query: name Text comes before the first section line, or the line is mistyped
The dynamic action's document is empty, or ignores the page The page items the queries use are not in Items to Submit
... needs the Standard tier or higher; this server is Community The template, output or data source needs a higher tier, or the server has no license