Apex_util.get_print_document

All,
below is a procedure (test_send_attachment1) that I cannot get to work and I've run out of ideas.
The value of xml_file_clob is detailed below and the rtf file spec is also provided. With these things, someone could, I believe, reproduce the problem.
I don't receive any errors and I do receive an email with a pdf attached. The problem is the pdf is 'malformed'
I should add that if I save the query that was used to generate this xml and upload to APEX the rtf file that I provided here and I test the report, it runs fine. Also, when I use the add-in to create the rtf with the below xml file and view the pdf, it processes just fine as well. So I think the "pieces" are correct.
I am using Oracle BI Publisher Template Builder for Word 10.1.3.4.1 (Build 130)
Thanks for having a look. I posted this here (even though it's related to BI Publisher) because I feel like the problem is with APEX_UTIL.get_print_document .... If the administrators feel this is better posted in another forum, let me know.
Regards.
============================================================================================
xml file :
============================================================================================
<ROWSET>
<ROW>
<PL_ID>1</PL_ID>
<PL_DESC>Yield</PL_DESC>
</ROW>
<ROW>
<PL_ID>2</PL_ID>
<PL_DESC>Dealer markup</PL_DESC>
</ROW>
<ROW>
<PL_ID>3</PL_ID>
<PL_DESC>Dealer Premium</PL_DESC>
</ROW>
<ROW>
<PL_ID>4</PL_ID>
<PL_DESC>Flats</PL_DESC>
</ROW>
</ROWSET>
========================================================================================================
rtf file:
========================================================================================================
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f36\froman\fcharset238\fprq2 Times New Roman CE;}
{\f37\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f39\froman\fcharset161\fprq2 Times New Roman Greek;}{\f40\froman\fcharset162\fprq2 Times New Roman Tur;}{\f41\froman\fcharset177\fprq2 Times New Roman (Hebrew);}
{\f42\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f43\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f44\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;
\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;
\red128\green128\blue128;\red192\green192\blue192;\red231\green243\blue253;}{\stylesheet{\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*
\cs10 \additive \ssemihidden Default Paragraph Font;}{\*
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{\*\ts15\tsrowd\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb
\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10
\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \sbasedon11 \snext15 \styrsid10303210 Table Grid;}}{\*\rsidtbl \rsid10303210}
{\*\generator Microsoft Word 10.0.6854;}{\info{\title This is a simple test}{\author g001131}{\operator g001131}{\creatim\yr2009\mo11\dy22\hr15\min38}{\revtim\yr2009\mo11\dy22\hr15\min41}{\version1}{\edmins3}{\nofpages1}{\nofwords17}{\nofchars97}
{\*\company JPMorgan Chase & Co.}{\nofcharsws113}{\vern16393}{\*\password 00000000}}{\*\xmlnstbl }\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\gutter0
\widowctrl\ftnbj\aenddoc\grfdocevents0\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1
\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct\asianbrkrule\rsidroot10303210 \fet0
{\*\wgrffmtfilter 013f}\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang
{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7
\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain
\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\insrsid10303210 This is a simple test
\par }\trowd \irow0\irowband0\ts15\trgaph108\trleft-108\trhdr\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10
\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid7238448\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb
\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth4428\clcbpatraw17 \cellx4320\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\clcbpat17\cltxlrtb\clftsWidth3\clwWidth4428\clcbpatraw17 \cellx8748\pard \ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid7238448 {\b\insrsid10303210 Pl Id}{\insrsid10303210\charrsid10303210 \cell }{
\b\insrsid10303210 Pl Desc}{\insrsid10303210\charrsid10303210 \cell }\pard \ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0 {\insrsid10303210 \trowd \irow0\irowband0\ts15\trgaph108\trleft-108\trhdr\trbrdrt
\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10
\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid7238448\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb
\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \clcbpat17\cltxlrtb\clftsWidth3\clwWidth4428\clcbpatraw17 \cellx4320\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\clcbpat17\cltxlrtb\clftsWidth3\clwWidth4428\clcbpatraw17 \cellx8748\row }\trowd \irow1\irowband1\lastrow \ts15\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv
\brdrs\brdrw10 \trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid7238448\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl
\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth4428\clshdrawnil \cellx4320\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\cltxlrtb\clftsWidth3\clwWidth4428\clshdrawnil \cellx8748\pard \ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid7238448 {\field\flddirty{\*\fldinst {\cf9\insrsid10303210\charrsid10303210  FORMTEXT }{
\cf9\insrsid10303210\charrsid10303210 {\*\datafield 8001000000000000055465787431000246200000000000103c3f666f722d656163683a524f573f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text1}{\*\ffdeftext F }{\*\ffstattext
<?for-each:ROW?>}}}}}{\fldrslt {\cf9\lang1024\langfe1024\noproof\insrsid10303210\charrsid10303210 F }}}\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\field\flddirty{\*\fldinst {\insrsid10303210\charrsid10303210  FORMTEXT }{
\insrsid10303210\charrsid10303210 {\*\datafield 80010000000000000554657874320005504c5f49440000000000093c3f504c5f49443f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text2}{\*\ffdeftext PL_ID}{\*\ffstattext <?PL_ID?>}}}}
}{\fldrslt {\lang1024\langfe1024\noproof\insrsid10303210\charrsid10303210 PL_ID}}}\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\insrsid10303210 \cell }{\field\flddirty{\*\fldinst {\insrsid10303210\charrsid10303210  FORMTEXT }{
\insrsid10303210\charrsid10303210 {\*\datafield 80010000000000000554657874330007504c5f4445534300000000000b3c3f504c5f444553433f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text3}{\*\ffdeftext PL_DESC}{\*\ffstattext
<?PL_DESC?>}}}}}{\fldrslt {\lang1024\langfe1024\noproof\insrsid10303210\charrsid10303210 PL_DESC}}}\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\field\flddirty{\*\fldinst {\cf9\insrsid10303210\charrsid10303210  FORMTEXT }{
\cf9\insrsid10303210\charrsid10303210 {\*\datafield 8001000000000000055465787434000220450000000000103c3f656e6420666f722d656163683f3e0000000000}{\*\formfield{\fftype0\ffownhelp\ffownstat\fftypetxt0{\*\ffname Text4}{\*\ffdeftext  E}{\*\ffstattext
<?end for-each?>}}}}}{\fldrslt {\cf9\lang1024\langfe1024\noproof\insrsid10303210\charrsid10303210  E}}}\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\insrsid10303210 \cell }\pard
\ql \li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0 {\insrsid10303210 \trowd \irow1\irowband1\lastrow \ts15\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10
\trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 \trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid7238448\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol\tblind0\tblindtype3 \clvertalt\clbrdrt
\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth3\clwWidth4428\clshdrawnil \cellx4320\clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10
\cltxlrtb\clftsWidth3\clwWidth4428\clshdrawnil \cellx8748\row }\pard \ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {\insrsid10303210
\par
\par }}
===========================================================================================
PROCEDURE DEFINITION
===========================================================================================
procedure test_send_attachment1 is
l_id number;
l_document blob;
v_data clob;
v_fmt clob;
begin
select xml_file_clob, rtf_layout_clob
into v_data, v_fmt
from profitauto.xml_test1
where xml_id = 10;
l_document :=
apex_util.get_print_document(p_report_data => v_data
,p_report_layout => v_fmt
,p_report_layout_type => 'rtf'
,p_document_format => 'pdf');
l_id :=
apex_mail.send(p_to => [email protected]
,p_from => '[email protected]'
,p_subj => 'test_send_attachment1'
,p_body => 'Please review the attachment.'
,p_body_html => 'Please review the attachment');
apex_mail.add_attachment(p_mail_id => l_id
,p_attachment => l_document
,p_filename => 'mydocument.pdf'
,p_mime_type => 'application/pdf');
end test_send_attachment1;

Anyone?

Similar Messages

  • Making apex_util.get_print_document return an error message

    We are using apex_util.get_print_document in a process to run a report something like this:
    declare
       l_report blob := null;
    begin
        l_report := apex_util.get_print_document (
            p_application_id      => :APP_ID,
            p_report_query_name   => 'report_query_name',
            p_report_layout_name  => 'report_layout_name',
            p_report_layout_type  => 'rtf',
            p_document_format     => 'rtf'
       if l_report is not null and dbms_lob.getlength(l_report) > 0 then
          apex_application.g_print_success_message := 'Report Created.<br>';       
          INSERT INTO reports (attachment, date_created, filename, mime_type)
          VALUES (l_report, sysdate, 'report.rtf', 'text/rtf' );       
       else       
          apex_application.g_print_success_message := '<span style="color:#CC0000">There was a problem creating the report.</span><br>';   
       end if; 
    end;And this works well most of the time. The problem is, if the report fails for some reason, apex_util.get_print_document gives no information whatsoever as to what went wrong. Is there any way at all we can find out what the problem was?
    Application Express 4.0.2.00.07
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

    Hi,
    add exception to your code.
    declare
       l_report blob := null;
    begin
        l_report := apex_util.get_print_document (
            p_application_id      => :APP_ID,
            p_report_query_name   => 'report_query_name',
            p_report_layout_name  => 'report_layout_name',
            p_report_layout_type  => 'rtf',
            p_document_format     => 'rtf'
       if l_report is not null and dbms_lob.getlength(l_report) > 0 then
          apex_application.g_print_success_message := 'Report Created.<br>';       
          INSERT INTO reports (attachment, date_created, filename, mime_type)
          VALUES (l_report, sysdate, 'report.rtf', 'text/rtf' );       
       else       
          apex_application.g_print_success_message := '<span style="color:#CC0000">There was a problem creating the report.</span><br>';   
       end if; 
    EXCEPTION
       WHEN OTHERS THEN
          raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    end;This will give proper error message.
    Hope this will helps you.
    Regards,
    Jitendra

  • APEX_UTIL.GET_PRINT_DOCUMENT Error Unable to get the document

    Hi,
       I am working on Oracle APEX 4.1 to send the report as an attachment through mail  I am unable to get the document while calling the APEX_UTIL.get_print_document. I have created a report query and report template (rtf template) so as to send the report as an email attachment. The report works fine individually upon clicking of button so there is no issue in BI publisher configuration. I am sure there is something very trivial which I am missing out here. Any help will be appreciated.
    Declare
       l_id number;
       l_document BLOB;
       l_error_msg varchar2(2000);
    BEGIN
       l_document := APEX_UTIL.GET_PRINT_DOCUMENT
             p_application_id=>'123',
             p_report_query_name=>'Sample_Report',   
             p_report_layout_name=> 'Sample_Report',
             p_report_layout_type=>'RTF',
             p_document_format=>'PDF',
             p_print_server => 'f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=Sample_Report'
       IF l_document is null
       THEN
           dbms_output.put_line( ' no report returned');
          l_error_msg:='<html> <body> <h1 > Apologies the report was not returned from the apex , as there is some printing issues </h1> </body> </html> ';
       ELSE
          l_error_msg:=null;
       END IF;
       IF l_error_msg IS NULL THEN
           l_id := APEX_MAIL.SEND(
           p_to => '[email protected]',
           p_from => '[email protected]',
           p_subj => 'APEX_MAIL with attachment',
           p_body => 'Please review the attachment.',
           p_body_html => '<b>Please</b> review the attachment' || l_error_msg);
          dbms_output.put_line(l_id);
          IF l_document is not null then
             APEX_MAIL.ADD_ATTACHMENT (
                        p_mail_id => l_id,
                        p_attachment => l_document,
                        p_filename => 'Sample_Report.pdf',
                        p_mime_type => 'application/pdf');
          END IF;
    END IF;
    END;
    Here the output says no report returned.
    Thanks & Regards
    Ahmed

    Try removing the parameter p_print_server from the call.  This will use your default print server which should already be configured to use the BI Publisher engine.

  • APEX_UTIL.GET_PRINT_DOCUMENT always returning empty BLOB

    Dear community,
    I have a huge problem when using the function APEX_UTIL.GET_PRINT_DOCUMENT in a job or database procedure.
    The following code runs perfectly when I integrate it in the APEX application directly e.g. using a button to execute it (of course I use an anonymous PL/SQL block in APEX itself). But when I run the same code as a procedure or job in the APEX database itself I always receive a mail with an empty PDF:
    CREATE OR REPLACE PROCEDURE APEX_DRUG_SAFETY.CALL_MAIL
    is
    l_id number;
    l_document BLOB;
    BEGIN
    wwv_flow_api.set_security_group_id;
    l_document := APEX_UTIL.GET_PRINT_DOCUMENT
    +(+
    p_application_id=>'105',
    p_report_query_name=>'TestReport',
    p_report_layout_type=>'pdf',
    p_document_format=>'pdf'
    +);+
    l_id := APEX_MAIL.SEND
    +(+
    p_to        => '[email protected]',
    p_from      => '[email protected]',
    p_subj      => 'sending PDF via print API',
    p_body      => 'Please review the attachment.',
    p_body_html => 'Please review the attachment.'
    +);+
    APEX_MAIL.ADD_ATTACHMENT
    +(+
    p_mail_id    => l_id,
    p_attachment => l_document,
    p_filename   => 'mydocument.pdf',
    p_mime_type  => 'application/pdf'
    +);+
    wwv_flow_mail.push_queue(
    P_SMTP_HOSTNAME => 'DESMTP.TEST.COM',
    P_SMTP_PORTNO => '25');
    end;
    The problem is that the function APEX_UTIL.GET_PRINT_DOCUMENT always returns an empty BLOB when executed outside of the APEX application. I found this issue in several other posts in this forum but I did not find a solution.
    The mail transmission itself works perfectly. Also with an attachment if e.g. I use another BLOB already stored in the database for testing purposes. So it is not the mail transmission that causes the problem but the empty variable l_document that is still empty.
    Thanks in advance for the help.

    user9007075 wrote:
    Dear community,
    wwv_flow_api.set_security_group_id;
    you should be using this
        l_workspace_id := apex_util.find_security_group_id (p_workspace => 'YOUR_WORKSPACE_NAME');
        apex_util.set_security_group_id (p_security_group_id => l_workspace_id);
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_util.htm#AEAPI512

  • Apex_util.get_print_document with bind

    All,
    I'm trying to create a process to bulk print a report to the file system using the API apex_util.get_print_document. Is there a way to pass bind variables to the report query when using this API? If not, has anyone come up w/another solution on mass printing reports that have parms?
    Thanks,
    Paul

    Hi Paul,
    APEX_UTIL API consists of 4 different GET_PRINT_DOCUMENT Functions based on parameters types(Function Overloading) that are being passed. If you look at the function where CLOB is the data type for parameter p_report_data, the bind variables can be passed to the SQL which willl be used by DBMS_XMLGEN or other XML/CLOB generation API's.
    I have used DBMS_XMLGEN to generate the CLOB data which intern used by GET_PRINT_DOCUMENT function.
    Regards
    Shesh

  • Apex_util.get_print_document results in "503-service unavailable"

    I'm using APEX 4.2.0.3.00.08 with GlassFish 3.1.2.2 on an Oracle 10.2.0.5 database.
    Recently I created a report-query together with a xsl-fo report-layout created in Altova Stylevision. I've enabled and configured print-options and when I press my application button, I'm perfectly capable of viewing and/or saving the pdf-version of my report.
    Additionally I want to save my report as BLOB in the database, but when I try this using apex_util.get_print_document, all I get in my table is a html-page containing the message "503-service unavailable".
    I used the following page as reference:
    Creating High Fidelity PDF Reports with Oracle Application Express but apparently I'm missing something or doing something wrong......I truly hope there's someone out here to help me!!
    Thanks in advance!

    Hello Mike,
    I've been trying to create an application on apex.oracle.com to reproduce the problem, but I can't seem to get it to work.
    I've uploaded a very simple layout created in StylusStudio, a simple query on the EMP-table only containgin FIRST_NAME, LAST_NAME and EMAIL and when I add the layout to the query and press "Test report", it works fine.
    When I run the report from my application, it only shows a pdf with a thick, horizontal lines, like it's showing only empty cell borders.
    Meanwhile I found out that the APEX-listener keeps reporting similair errors, even when I use that same simple stylesheet (created with StylusStudio) on the EMP-table, even when the stylesheet does not contain any special characters at all. In stead of the message starting with INFO: Character decoding failed. Parameter [#x200B;</xsl:text> , it then ignores the complete xslt-stylesheet (the complete contents of the stylesheet is between the brackets, in stead of just the string containg the special chars).
    To be honest I'm a little lost now. First my focus was on how to get rid of the special characters, but now it looks like, even when I might succeed in that, it doesn't even solve my problem.
    Any idea why my application doesn't show me the same report I see when testing the report-query?
    The application can be found here:
    https://apex.oracle.com/pls/apex/htmldb/f?p=29586
    The bottom region is an attempt to show the pdf with the highest id, but I think it does not show the actual pdf (http-404)
    The source for that PL/SQL region is:
    declare
      src_  varchar2(256);
      mime_ varchar(48);
      id_   number;
    begin
    select max(id)
    into id_
    from report_archive;
        select mimetype
          into mime_
          from report_archive
         where id = id_;
        src_ := 'src="#OWNER#.download_doc?i_doc_id=' || id_ || '" ';
        htp.p('<div style="">');
        if instr(mime_,'pdf') > 0 then
          htp.p('<embed height="800" width="1200" name="statement" ');
        elsif instr(mime_,'excel') > 0 then
          htp.p('<embed height="800" width="1200" name="statement" ');
        else
          htp.p('<embed height="800" name="statement" ');
        end if;
        htp.p(src_);
        htp.p('type="' || mime_ || '" />');
        htp.p('</div>');
    exception
       when no_data_found then
          null;
    end;
    I really hope we can solve this!!!!
    Best regards,
    Marco

  • Apex_util.get_print_document in sql developer

    I have not been successful in getting apex_util.get_print_document to work in sql developer, the return value is always null and inserted into the table. Inside of APEX it works fine, so I figured I had to set workspace id, but that did not help. Heres the basic code.
    declare
    rpt_blob BLOB;
    begin
    wwv_flow_api.set_security_group_id(my ws id);
    rpt_blob := APEX_UTIL.GET_PRINT_DOCUMENT (
    p_application_id => 122,
    p_report_query_name => 'NYARNG_unit',
    p_report_layout_name => 'TEST',
    p_report_layout_type => 'xsl-fo',
    p_document_format => 'pdf',
    p_print_server => null);
    insert into report_archive_tbl values ('test'||sysdate||'.pdf','application/pdf',rpt_blob,sysdate,'tread');
    end;

    Try
    wwv_flow_api.set_security_group_id;instead of wwv_flow_api.set_security_group_id(my ws id);
    Regards,
    Hari

  • Apex_util.get_print_document returns empty blob

    Hi,
    I'm trying to convert a xsl-fo template into PDF. I have the following code:
    begin
    declare
    v_retval blob;
    v_data blob;
    v_xls clob;
    v_xml_dat clob;
    begin
    select page_template
    into v_xls
    from flows_030100.wwv_flow_report_layouts
    where flow_id =101
    and report_layout_name = 'vv';
    v_xml_dat := to_clob('<data><row><dat1>fff</dat1></row></data>');
    v_data := wwv_flow_utilities.clob_to_blob(v_xml_dat);
    v_retval := apex_util.get_print_document (v_data,v_xls,'xsl-fo','pdf')
    htp.p(dbms_lob.getlength(v_retval));
    end;
    end;
    This returns 0 instead of some PDF document. I guess there is something wrong with my input, probably the XML data. Any thoughts?

    Anyone?

  • APEX_UTIL.GET_PRINT_DOCUMENT  not returning anything

    I have a report query and have provided a layout to print it
    I need to get the html generated from the report so that I can mail it.
    As I could not get the generated file in the PL/SQL package written , for quick testing I started testing using a SQL stmt to check for the length of the LOB
    select dbms_lob.getlength(APEX_UTIL.GET_PRINT_DOCUMENT (
    p_application_id=>my_app_id,
    p_report_query_name=>'name of qry',
    p_report_layout_name=>'name of layout',
    p_report_layout_type=>'rtf',
    p_document_format=>'htm')) lob_size
    from dual
    I also tried by providing the p_print_server => null in addition to the parameters passed.
    But the query returns NULL only.
    The qry and layout are correct as the query when tested in the edit qry screen in APEX shows the output report in the format required (including html , PDF etc)
    Any pointers ?
    Thx
    Edited by: user618186 on Apr 24, 2009 2:35 PM
    Edited by: user618186 on Apr 24, 2009 2:36 PM

    I have the same problem exactly...works as an APEX proc, will not work from sqlplus despite setting security group id. Mail works. Attachments with another BLOB works. But I can't get this function to give me the BLOB.

  • Call print apex_util.get_print_document() with page item values

    Hi all
    I ran into an issue that very frustrated as it sounds so simple.
    I'm in Apex 3.1.
    My database has table TAB_CLASSES, TAB_STUDENT
    My application has page 1 with P1_SID is student_ID
    I had an simple report query name Class_query, show all classes that a student attends
    select * from TAB_CLASSES where SID = :P1_SID;
    I also select option "include application and session information"
    I had report template Class_template
    In my application, I have a process tried to generate report list classes for all students.
    l_report blob;
    for x in (select * from TAB_STUDENT)
    loop
    :P1_SID := x.SID;
    l_report := apex_util.get_print_document (
    p_application_id => :APP_ID,
    p_report_query_name => 'Class_query',
    p_report_layout_name => 'Class_template',
    p_report_layout_type => 'rtf',
    p_document_format => 'pdf'
    insert all the l_report into database with SID as a part of l_report name (*) 
    end loop;
    After this, I got multiple of l_report blob in database, number of report is exactly number of student in the TAB_STUDENT table. The problem is that every report looks the same, and it got the information of only first student
    I guessed it did not pass the item value (P1_SID) every time it call the get_print_document, but it still shows in the report name (*)
    Please help me. Thanks for any idea.
    Teiv
    Edited by: teiviag on Mar 10, 2010 7:16 AM

    This post had the same problem with me
    [ http://forums.oracle.com/forums/thread.jspa?threadID=663186&start=0&tstart=0|http://forums.oracle.com/forums/thread.jspa?threadID=663186&start=0&tstart=0]
    Thanks for the post of Marc, about how variables are binding and calling by process, I changed my app design to have a sp to print and store the pdf file. Then in my app, I just called the sp and passed the P1_SID. It worked.
    Thanks.
    Edited by: teiviag on Mar 10, 2010 10:49 AM
    Edited by: teiviag on Mar 10, 2010 10:50 AM
    Edited by: teiviag on Mar 10, 2010 10:50 AM

  • Bug in apex_util.GET_PRINT_DOCUMENT?

    When call apex_util.get_print_document like this on apex.oracle.com
        t_pdf := apex_util.get_print_document( p_report_data => t_xml
                                                      , p_report_layout => t_xsl
    I get  a ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_LOB", line 710
    ORA-06512: at "APEX_040200.WWV_FLOW_UTILITIES", line 10589
    ORA-06512: at "APEX_040200.WWV_FLOW_UTILITIES", line 11053
    ORA-06512: at "APEX_040200.WWV_FLOW_UTILITIES", line 11138
    ORA-06512: at "APEX_040200.HTMLDB_UTIL", line 3255
    ORA-06512: at line 32
    That must be a bug, or not?

    The bug is caused by the fact that my template was selected from a table. Copying it to a temporary clob solves the problem.
    declare
      t_xml blob;
      t_pdf blob;
      t_xsl clob;
      t_xsl_ok clob;
      t_name varchar2(32767);
    begin
        select xml_data, name
        into t_xml, t_name
        from demo_xml
        where rowid = substr( apex_application.g_request, 8 );
        select xsl
        into t_xsl
        from demo_xsl
        where id = 1;
        dbms_lob.createtemporary( t_xsl_ok, true );
        dbms_lob.copy( t_xsl_ok, t_xsl, length( t_xsl ) );
        t_pdf := apex_util.get_print_document( p_report_data => t_xml
                                             , p_report_layout => t_xsl_ok
        dbms_lob.freetemporary( t_xsl_ok );
    end;

  • Using apex_util.get_print_document with DBMS Scheduler

    I'm trying to run report_query from DBMS_SCHEDULER job. When the job tries to execute I get this error in dba_scheduler_job_run_details. Notsure how to debug this. Any ideas?
    Select error#, additional_info from dba_scheduler_job_run_details where job_name ='TEST10'
    6502
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "APEX_030200.WWV_FLOW_RENDER_QUERY", line 644
    ORA-01003: no statement parsed
    ORA-06512: at "APEX_030200.WWV_FLOW_RENDER_QUERY", line 1469
    ORA-06512: at "APEX_030200.WWV_FLOW_UTILITIES", line 9233
    ORA-06512: at "APEX_030200.HTMLDB_UTIL", line 1836
    ORA-06512: at "SIS_EXPRESS.SIS_EXPRESS_REPORTS", line 867
    ORA-06512: at line 2
    DECLARE l_report_blob blob;
    l_id number;
    l_application_id report_scheduler_job.application_id%TYPE;
    l_application_owner report_scheduler_job.application_owner%TYPE;
    l_report_query_name report_scheduler_job.report_query_name%TYPE;
    l_report_layout_name report_scheduler_job.report_layout_name%TYPE;
    l_output_format varchar2(10);
    BEGIN
    l_report_blob := apex_util.get_print_document(
    p_application_id => l_application_id,
    p_report_layout_name => l_report_layout_name,
    p_report_query_name => l_report_query_name,
    p_report_layout_type => l_output_format,
    p_document_format => l_output_format,
    p_print_server => null);
    END:

    You must use a "replace" function in you sql querie for the special characters. for example:
    select replace(replace(customer_name,''&'',''%26amp;''),chr(39),''%26apos;'') customer_name
       from accounts

  • Running apex_util.get_print_document with APEX_MAIL

    I am trying to automate the running of an apex_util.get_print_document, emailing the output to my users. When the job tries to run I get this error in the log:
    ORA-20022: Null value supplied for parameter p_attachment.
    ORA-06512: at "FLOWS_030100.WWV_FLOW_MAIL", line 731
    ORA-06512: at "SIS_EXPRESS.SIS_EXPRESS_REPORTS", line 154
    ORA-06512: at line 2
    Not sure where I can check this to see the problem. Anybody do this before?
    BEGIN
    l_report_blob := apex_util.get_print_document(
    p_application_id => l_application_id,
    p_report_layout_name => l_report_query_name,
    p_report_query_name => l_report_query_name,
    p_report_layout_type => l_output_format,
    p_document_format => l_output_format,
    p_print_server => null);
    l_id := APEX_MAIL.SEND( p_to => '[email protected]',
    p_from => '[email protected]',
    p_subj => 'APEX_MAIL with attachment',
    p_body => 'Please review the attachment.',
    p_body_html => 'Please review the attachment' );
    APEX_MAIL.ADD_ATTACHMENT( p_mail_id => l_id,
    p_attachment => l_report_blob,
    p_filename => l_report_query_name,
    p_mime_type => l_mime_type);
    COMMIT;
    END;

    Hi Paul,
    APEX_UTIL API consists of 4 different GET_PRINT_DOCUMENT Functions based on parameters types(Function Overloading) that are being passed. If you look at the function where CLOB is the data type for parameter p_report_data, the bind variables can be passed to the SQL which willl be used by DBMS_XMLGEN or other XML/CLOB generation API's.
    I have used DBMS_XMLGEN to generate the CLOB data which intern used by GET_PRINT_DOCUMENT function.
    Regards
    Shesh

  • Apex_util.get_print_Document not working outside apex environment

    I am working on one of the assignment in Apex 4.0.2 .
    The requirement is to dynamically generate reports and mail to User using the Scheduler program(Pl/sql) -> dbms_scheduler.
    I have used BI publisher to create the template and xml data for the report(Excel) and used Apex_util.get_print_Document
    in the scheduler program (which is written outside Apex), but this is not working properly,sends blank report to email.
    Please suggest how to set the apex session and use Apex_util.get_print_Document to work properly outside apex env.

    Apex (PL/SQL web-enabled) code needs to execute inside an Oracle server session that has been properly and correctly initialised for executing web enabled PL/SQL code.
    An example of how to execute such PL/SQL by intialising a proper environment, is shown in {message:id=2251131}.
    Note that this will not be able to execute Apex pages (via the flow engine) that are not public - that needs a proper authenticated Apex web session. Which could be a tad complex to emulate in this fashion.

  • Apex_util.get_print_document not generating correct output

    hello,
    Basically what I've done is this.
    1) stored a very simple xml file in a clob field called xml_file_clob in a table called xml_test1
    2) stored an rtf file in a clob field called rtf_layout in a table called xml_test1
    3) created a procedure (below) called generate_report_as_blob which attempts to combine the xml and layout and generate a PDF from it which is stored into a blob field in the same table where 1) and 2) are above .....
    4) I have confirmed that taking the clobs in 1) and 2) from the table above and creating xml and rtf files on my desktop that I can open the rtf file in Word, load the xml file and preview it and it does render the pdf as intended (so I think my clobs in the table are good)
    5) run the procedure below. It compiles and runs with no errors but generates a file into the blob column that when downloaded to my desktop looks like the below output (when opening w/ pdf it says there was an error opening the file)
    Any thoughts are greatly appreciated. I feel like I'm really close and am excited about what I could do with this if this can work.
    Thanks in advance, KW
    =========================================================================
    MY PROC
    ============================
    procedure generate_report_as_blob is
    v_xml xmltype;
    rtf_layout clob;
    v_rpt_output blob;
    v_xml_rpt_data clob;
    begin
    select xml_file_clob, rtf_layout_clob
    into v_xml_rpt_data, rtf_layout
    from xml_test1
    where xml_id = 2;
    v_rpt_output :=
    apex_util.get_print_document(p_report_data => v_xml_rpt_data
    ,p_report_layout => rtf_layout
    ,p_report_layout_type => 'rtf'
    ,p_document_format => 'pdf'
    ,p_print_server => null);
    update xml_test1
    set rpt_pdf_output = v_rpt_output
    where xml_id = 2;
    commit;
    end generate_report_as_blob;
    ==========================================================================
    ==========================================================================
    MY OUTPUT (as apdf file) :
    =================
    %PDF-1.4
    1 0 obj
    <<
    /Type /Catalog
    /Pages 3 0 R
    >>
    endobj
    2 0 obj
    <<
    /Type /Info
    /Producer (Oracle BI Publisher 10.1.3.4.0)
    >>
    endobj
    3 0 obj
    <<
    /Type /Pages
    /Kids [
    /Count 0
    >>
    endobj
    4 0 obj
    <<
    /ProcSet [ /PDF /Text ]
    >>
    endobj
    xref
    0 5
    0000000000 65535 f
    0000000010 00000 n
    0000000065 00000 n
    0000000147 00000 n
    0000000208 00000 n
    trailer
    <<
    /Size 5
    /Root 1 0 R
    /Info 2 0 R
    /ID [<fdd8d0c54769561cc797a7c9d0ae42cd><fdd8d0c54769561cc797a7c9d0ae42cd>]
    >>
    startxref
    258
    %%EOF
    ====================================
    Edited by: Ken Wood on Oct 30, 2009 8:56 AM

    I have the same problem exactly...works as an APEX proc, will not work from sqlplus despite setting security group id. Mail works. Attachments with another BLOB works. But I can't get this function to give me the BLOB.

Maybe you are looking for

  • Video/audio glitches exporting to MPEG-2 in premiere pro CC

    Like another user from a post in February, I am experiencing a variety of glitches in saved mpg files. They are all from the same project file which is composed of footage shot with GoPro cameras. The project file itself does not contain any of the a

  • ST22 RUNTIME ERROR

    Dear All, i m getting dump in st22.DBIF_REPO_SQL_ERROR but i m unable to understand this dump error.plz any1 tell me what is this ??? st22 dump log i have attached with it. What happened? The system is no longer linked to an ORACLE instance. No furth

  • Application Manager Download

    Everytime I try to launch my trial of Adobe Illustrator I am told I need a copy of Application Manager which I already have. I have since deleted that copy and dowloaded the latest with no effect. Can anyone help?

  • What to do when Dr. Pepper is spilled on Macbook Air?

    How did this happen? I had an almost-empty glass of Dr. Pepper sitting beside my computer (stupid decision to leave it there, I know,) and my dog was laying beside me.  I was on iTunes about to sync some music I had just added to my library to my iPh

  • When I Print a cd jewel case the song list is printed over each other in 11.0, what's the fix?

    When printing a cd jewel case the song list prints over each other in i-tunes 11.0. Is there a fix for this?