Skip to main content

Additional Features

PDF Document Properties

Every document has properties such as title ,tags ,created date ,modified date , and comments.
With AOP, you can dynamically assign this documentation information to a document directly within the data.

You can provide data for the title, tags, and comments directly from the data source. However, you need to provide the created date and modified date on INIT PL/SQL region.

Supported for DOCX, XLSX and PPTX outputs.

aop_api_pkg.g_output_modified_date := '2024/11/11';
aop_api_pkg.g_output_created_date := '2024/10/11';

Note: The created and modified dates are set manually for user convenience, allowing users to adjust the dates as they prefer.
EXAMPLE USAGE:

select 'file1' AS "filename",
cursor (
select c.cust_first_name as "cust_first_name",
c.cust_last_name as "cust_last_name",
c.cust_city as "cust_city",
c.cust_last_name || ' Order_summary' as "title",
'Order' as "tag",
'product_name' as "comment",
cursor (
select o.order_total as "order_total",
'Order ' || rownum as "order_name",
cursor (
select p.product_name as "product_name",
i.quantity as "quantity",
i.unit_price as "unit_price",
p.category as "category",
'true' as "category_group"
from aop_sample_order_items i,
aop_sample_product_info p
where o.order_id = i.order_id
and i.product_id = p.product_id
order by p.category asc
) "product"
from aop_sample_orders o
where c.customer_id = o.customer_id
) "orders"
from aop_sample_customers c
where customer_id = 1
) as "data"
from dual;

Sample template image for documentation information

alt text

 pdf_document_properties.docx  

Password Encryption

Available From: v25.1

This feature allows the generated document to be password protected. Supported template and output type is: DOCX, DOCM, XLSX, XLSM, PPTX, PPTM and PDF

You can provide the password using the following Init PL/SQL.

aop_api_pkg.g_output_read_password:= 'read_password';

Example

The following example demonstrates on how password encryption can be done in the generated output.

Data Source

In the Init PL/SQL the following commands were passed:

aop_api_pkg.g_output_read_password:= 'aop-pass';

Here by the data source used for the demonstration of Password Encryption.

select
'file1' as "filename",
cursor(
select
c.cust_first_name as "cust_first_name",
c.cust_last_name as "cust_last_name",
c.cust_city as "cust_city",
cursor(select o.order_total as "order_total",
'Order ' || rownum as "order_name",
cursor(select p.product_name as "product_name",
i.quantity as "quantity",
i.unit_price as "unit_price",
APEX_WEB_SERVICE.BLOB2CLOBBASE64(p.product_image) as "image",
--'https://www.apexrnd.be/ords/apexofficeprint/aop/image?product_id='||p.product_id as "image",
40 as "image_max_width"
from aop_sample_order_items i, aop_sample_product_info p
where o.order_id = i.order_id
and i.product_id = p.product_id
) "product"
from aop_sample_orders o
where c.customer_id = o.customer_id
) "orders"
from aop_sample_customers c
where customer_id = 1
) as "data"
from dual

Template

Here are the templates for password encryption.

 template.docx    template.xlsx    template.pptx  

Output

Upon processing the data source and template, the generated outputs are:
Password For these output: aop-pass

 output.docx    output.xlsx    output.pptx  

Useful Output Types

APEX Office Print offers various options output types for the processed files. These options are available in the "Output To" field in the "Settings" section. The available options are as follows.

Here are a few of these options, explained below:

Count Tags

The Count Tags output type in AOP provides an option to get the tags and their counts from the template.
It helps verify the tag names, their case sensitivity, occurrences, and structure within the template.

Example:

Following is an example on how this could be used:

PLSQL code:

Here is an example of PL/SQL code used to call AOP, which returns a JSON response in a CLOB.

declare
l_output_filename varchar2(300);
l_blob blob;
l_clob clob;
begin
l_blob := aop_api_pkg.plsql_call_to_aop(
p_data_type => aop_api_pkg.c_source_type_none,
p_template_type => aop_api_pkg.c_source_type_apex,
p_template_source => 'aop_template_d01.docx',
p_output_type => aop_api_pkg.c_count_tags,
p_output_filename => l_output_filename,
p_aop_url => :AOP_URL,
p_api_key => :AOP_API_KEY,
p_app_id => :APP_ID
);

l_clob := aop_api_pkg.blob2clob(l_blob);

l_clob := replace(l_clob,'],','],'||CHR(10));
return l_clob;
end;

Template

The template includes tags of AOP.

alt text

 template.docx  

Output:

When the above PL/SQL code and template are provided, the following output is generated by AOP.

{
"{cust_last_name}": 1,
"{cust_first_name}": 2,
"{cust_city}": 1,
"{#orders}": 2,
"{#product}": 2,
"{product_name}": 2,
"{/product}": 2,
"{order_total}": 2,
"{/orders}": 2,
"{%image}": 1,
"{#unit_price>80}": 1,
"{unit_price}": 2,
"{/unit_price>80}": 2,
"{^unit_price>80}": 1,
"{quantity}": 1,
"{unit_price*quantity}": 1,
}

The Count Tags output provides the count of each tag used in the template, along with the number of times each tag appears.

For example:

  • {cust_first_name}: 2 means the tag {cust_first_name} is used 2 times in the template.
  • {cust_last_name}: 1 indicates the tag {cust_last_name} appears once.

NOTE: It is available for all template types except PDF.

Form Fields

Form Fields is a special output type that allows you to retrieve the form fields from the PDF template.
This is useful when you want to use the form fields in your template.
The form fields information are returned in JSON format.

Example:

Following is an example on how this could be used:

PLSQL code

Here is an example of PL/SQL code used to call AOP, which returns a JSON response in a CLOB.

declare
l_output_filename varchar2(300);
l_blob blob;
l_clob clob;
begin
l_blob := aop_api_pkg.plsql_call_to_aop(
p_data_type => aop_api_pkg.c_source_type_none,
p_template_type => aop_api_pkg.c_source_type_apex,
p_template_source => 'aop_pdf_form_filled.pdf',
p_output_type => aop_api_pkg.c_form_fields,
p_output_filename => l_output_filename,
p_aop_url => :AOP_URL, -- Your url
p_api_key => :AOP_API_KEY,
p_app_id => :APP_ID
);

l_clob := aop_api_pkg.blob2clob(l_blob);

l_clob := replace(l_clob,'],','],'||CHR(10));

return l_clob;
end;

Template

The template consists a form field where, AOP will return form field information such as the field name, its type, and value.

alt text

 template.pdf  

Output

When the above PL/SQL code and template are provided, the following output is generated by AOP.

{"First Name":[{"type":"string","value":"Dimitri"}],
"Last Name":[{"type":"string","value":"Gielis"}],
"radiolist":[{"type":"radio","options":["List A","List B"],
"value":"List A"}],
"radio":[{"type":"radio","options":["A","B"],
"value":"B"}],
"Agree":[{"type":"boolean","value":true}]}

The returned JSON contains the following information:

  • field name: The name of the form field.
  • type: The type of the form field.
  • value: The value of the form field.

Where,

  • field name: First Name
  • type: string
  • value: Dimitri

Please go through our sample application for implementation details.

Change Locale

Available From: v25.1

AOP provides the option to change the locale of the documents. Changing locale helps Ms Office and LibreOffice apps to interpret them properly. It does not change the existing text itself. AOP has a map of supported languages and their respective code. Provide the name of the langauage to change the locale. Using language/locale not defined in AOP will result in error.

Available languages
Language Language Tag
Afrikaans af
Albanian sq
Amharic am
Arabic ar
Armenian hy
Assamese as
Basque eu
Belarusian be
Bengali bn
Bosnian bs
Bulgarian bg
Catalan ca
Chinese zh
Croatian hr
Czech cs
Danish da
Dutch nl
English en
Esperanto eo
Estonian et
French fr
Galician gl
Georgian ka
German de
Greek el
Gujarati gu
Hebrew he
Hindi hi
Hungarian hu
Icelandic is
Indonesian id
Irish ga
Italian it
Japanese ja
Kannada kn
Kazakh kk
Khmer km
Korean ko
Kurdish ku
Lao lo
Latvian lv
Lithuanian lt
Macedonian mk
Malayalam ml
Marathi mr
Mongolian mn
Nepali ne
Norwegian no
Oriya or
Persian fa
Polish pl
Portuguese pt
Punjabi pa
Romanian ro
Russian ru
Serbian sr
Sinhala si
Slovak sk
Slovenian sl
Spanish es
Swahili sw
Swedish sv
Tamil ta
Telugu te
Thai th
Turkish tr
Ukrainian uk
Uzbek uz
Vietnamese vi
Welsh cy
Xhosa xh
Zulu zu

Example

The example below shows you how to change locale of a document. "nepali" is provided as the language in the example below. AOP will add its respective language code that is used and understood by the document to the document.

Data Source

Hearby the Init PL/SQL code to set the local of the output.

aop_api_pkg.g_output_locale  := "nepali";

Output

The selected output type is pdf, and upon processing the following result is obtained.

 changed_locale.pdf