Additional Features
PDF Document Properties
Not only for PDF, it can be used for WORD, EXCEL Too. Add it in the example
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.
- INIT/PLSQL Option
- JSON Option
aop_api_pkg.g_output_modified_date := '2024/11/11';
aop_api_pkg.g_output_created_date := '2024/10/11';
{
"output": {
"output_type": "date_information",
"output_modified_date": "2024/11/11",
"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:
- SQL
- PL/SQL returning SQL
- PL/SQL returning JSON
- JSON
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;
declare
l_return clob;
begin
l_return := q'[
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;
]';
return l_return;
end;
declare
l_cursor sys_refcursor;
l_return clob; -- can also be varchar2, make sure it corresponds to the structure in the JSON
begin
apex_json.initialize_clob_output(dbms_lob.call, true, 2);
open l_cursor for
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;
apex_json.write(l_cursor);
l_return := apex_json.get_clob_output;
return l_return;
end;
[
{
"filename": "file1",
"data": [
{
"cust_first_name": "John",
"cust_last_name": "Dulles",
"cust_city": "Sterling",
"title": "Dulles Order_summary",
"tag": "Order",
"comment": "product_name",
"orders": [
{
"order_total": 2380,
"order_name": "Order 1",
"product": [
{
"product_name": "Bag",
"quantity": 4,
"unit_price": 125,
"category": "Accessories",
"category_group": true
},
{
"product_name": "Wallet",
"quantity": 2,
"unit_price": 50,
"category": "Accessories",
"category_group": true
},
{
"product_name": "Belt",
"quantity": 2,
"unit_price": 30,
"category": "Accessories",
"category_group": true
},
{
"product_name": "Mens Shoes",
"quantity": 2,
"unit_price": 110,
"category": "Mens",
"category_group": true
},
{
"product_name": "Jacket",
"quantity": 3,
"unit_price": 150,
"category": "Mens",
"category_group": true
},
{
"product_name": "Business Shirt",
"quantity": 3,
"unit_price": 50,
"category": "Mens",
"category_group": true
},
{
"product_name": "Trousers",
"quantity": 3,
"unit_price": 80,
"category": "Mens",
"category_group": true
},
{
"product_name": "Ladies Shoes",
"quantity": 2,
"unit_price": 120,
"category": "Womens",
"category_group": true
},
{
"product_name": "Blouse",
"quantity": 3,
"unit_price": 60,
"category": "Womens",
"category_group": true
},
{
"product_name": "Skirt",
"quantity": 3,
"unit_price": 80,
"category": "Womens",
"category_group": true
}
]
}
]
}
]
}
]
Sample template image for documentation information
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.
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.
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.