48.6 GENERATE_DOCUMENT Function Signature 5

Generates a document using an custom template stored in an OCI Object Storage Bucket and return the contents.

Can only be used when Oracle Document Generator Pre-built Function is configured as print server in the instance.

Syntax

APEX_PRINT.GENERATE_DOCUMENT (
    p_data                   IN              CLOB,
    p_template_type          IN              t_template_type,
    p_template_bucket        IN              VARCHAR2,
    p_template_namespace     IN              VARCHAR2,
    p_template_object        IN              VARCHAR2,
    p_output_type            IN              t_output_type DEFAULT c_output_pdf,
    p_output_password        IN              VARCHAR2      DEFAULT NULL)
    RETURN BLOB;

Parameters

Parameter Description
p_data Data for the document. Currently JSON format only.
p_template_type Type of the template.
p_template_bucket Name of the Object Storage bucket.
p_template_namespace Object Storage namespace.
p_template_object Name of the Template Object in Object Storage.
p_output_type The type of document.
p_output_password The password to needed to open the generated document. PDF only.

Example

The following example gets a PDF using a custom JSON data and a custom template stored in an OCI Object Storage Bucket.

declare
    l_document blob;
    l_json     sys.json_object_t := sys.json_object_t();
begin

    l_json.put( 'title', 'Hello World' );

    l_document :=
        apex_print.generate_document (
            p_data                => l_json.to_clob(),
            p_template_type       => apex_print.c_template_docx,
            p_template_bucket     => 'mybucket',
            p_template_namespace  => 'mynamespace',
            p_template_object     => 'mytemplate.docx',
            p_output_type         => apex_print.c_output_pdf,
            p_output_password     => '...put your password here...' );

    apex_http.download(
        p_blob           => l_document,
        p_content_type   => 'application/pdf',
        p_filename       => 'hello-world.pdf' );

end;