Outputting pdf to browser from a db

Hi , I have a web-app that queries a db for a pdf file (Blob) and then outputs the file to the browser. It seems to be downloaded to the browser, but then nothing is displayed. I've used the same code for other apps, which all work fine. I believe it might be server related as it works fine on Tomcat, but not on SunONE. Any ideas? Thanks
             Blob b = rs.getBlob(1);
             int len = 0;
             InputStream is = b.getBinaryStream();
             long length = b.length();
             byte[] x = new byte[10240];
             resp.setHeader("Content-disposition", "filename=temp.pdf");
             resp.setContentType("application/pdf");
             resp.setContentLength( (int) length);
             DataOutputStream o = new DataOutputStream(resp.getOutputStream());
             while ( (len = is.read(x)) != -1)
                o.write(x, 0, len);
             o.flush();
             o.close();
             is.close();

Hi guys,
In my application I am uploading documents of all type and extensions into the orcale database as BLOB objects. When the user clicks a url to view a document I grab the url and then making use of the document ID requested, I query the database and retrieve the corresponding BLOB object as a byte array and then stream the byte array to display the file/image in the browser.
(The application is so designed that all the column values of a row are returned as objects, and then I cast the objects based on the need. In my case I get an object corresponding to my document, which I cast it to byte [] and then stream it.)
I am able to retrieve documents of type MS word and text files. But when I retrieve images I get a blurred/corrupted image. ANd with PDF files I get the following message:
"There was an error processing a page. Too few Operands." and also "Unknown token '' was found".
Even when I open excel sheets and powerpoint files I get an error message.
I am comparing the length of the blob as stored in the db and also length of the blob after retrieving from the db and they are same.
I am using Internet Explorer 6.0 as my browser, Tomcat 4.1 as my app server and Java 1.4.
This is my servlet code.
//retreiving the row from the DB and then casting the Object to byte[]
byte[] bytes = (byte[])dataSetRow.getObjectValue(7);
String contentType = dataSetRow.getValue(2);
response.setContentType(contentType);
String blobStrLen = dataSetRow.getValue(5);
int iLen = Integer.parseInt(blobStrLen);
response.setContentLength(iLen);
ByteArrayOutputStream output = new ByteArrayOutputStream(iLen);
output.write(bytes, 0, iLen);
ServletOutputStream out = response.getOutputStream();
out.write(output.toByteArray(), 0, output.size());
out.flush();
out.close();
Any help will be greatly appreciated , if you need more details please let me know.
Thanks,
anil.

Similar Messages

  • Unable to View PDF in Browser from a Servlet.

    Hi,
    I am facing a problem while trying to dynamically generate PDF from a Servlet and display it in the browser(IE 6.0 sp2)
    The scenario is as follows:
    i have a link which on clicking (using javascript) moves to a Servlet(say Dispatcher Servlet).This servlet forwards the control to another Servlet(say PDF Renderer Servlet) which generates the PDF and tries to display the results to the browser.
    The PDF does get generated.
    However in the pop-up i get a alert message to either open or save the PDF.But when i try to do so the message i get is that IE failed to communicate with the server.
    The code i am using to display the PDF is as follows
    ByteArrayOutputStream outfile = pdfTransformer.transform(xmlString,container);
    byte[] content = outfile.toByteArray();
    response.setContentType("application/pdf");
    response.setContentLength(content.length);
    response.setHeader("Content-Disposition", "inline; filename=\"" + pdfName + "\"");
    ServletOutputStream out= response.getOutputStream();
    out.write(content);
    out.flush();
    out.close();
    Any suggestions would be a great help.
    Thanks

    Hi,
    I have the same code as Viv above and I am generating pdf using fdf file format. the code works upto the point where it generates pdf. I am not setting the header to open the file in the same browser or new window:
    (not in my code)
    response.setHeader("Content-Disposition", "inline; filename=\"" + pdfName + "\"");it was working fine last week and now it starts to give a pop up box with only one option of saving the pdf file, there is no option to open it. when I save it the data in the file is lost, its just a fblank form. I am using IE 6.0.2900
    any suggestions?
    Ali

  • Error returned in Acrobat X Pro when attempting to output pdf full text from Proquest database.

    Contacted Proquest and they said to contact Adobe. Recently installed CS5, so I now have newer Acrobat version from before. This newer version isn't playing well. Can anyone help?
    This is my original plea to Proquest:
    Description:
    Recently had Adobe Creative Suite (CS5) installed on my machine. Now when I attempt to download full text pdf I receive an error message when trying to open the downloaded file. "There was an error opening this document. The file is damaged and could not be repaired."
    I can view pdf within Proquest window, but problems occur when I try to open the download - defaults to Acrobat X Pro, not standard Reader. I also get an error message when trying to email it. The only outputting method that seems to work is the Export/Save option.
    I tried on another machine that uses Acrobat Reader XI and all worked fine.
    BTW - I am working in Firefox.
    Thanks in advance for any assistance.

    Here are some screenshots:

  • Open PDF in browser from Flash

    I want people to be able to click a link in my Flash site and
    for Acrobat to open the PDF, or have it open in their browser,
    instead of downloading the PDF to their desktop. Thanks!

    You can click on the button/ go to windows/ behaviors/ click
    on the drop down list of the plus sign symbol/ web/ go to web page/
    then you put NameofyourFile.pdf......... But I have an extra
    question if someone could help when i publish my movie after doing
    this the file opens twice why is this happening how can i fix
    this?

  • How do I link to Anchor Text from browser to PDF file exported from InDesign?

    I see that this question was asked previously but not answered:
    http://forums.adobe.com/message/3737541
    I need a way to link to topics (from an HTML page) within a structured PDF file generated from InDesign, i.e. one that has an interactive bookmarks
    panel, that doesn't break the links when the file is updated.
    In particular, I don't want to refer to:
    *  page numbers because the document will repaginate when it is updated, breaking existing links
    * named destinations that are numeric as addition/deletion of topics renumbers the named destinations, breaking the links.
    Is there any option in InDesign that creates named destinations derived from bookmark titles as that would seem to solve my problem?
    I have a similar need, but I have not been able to find an answer anywhere online, even after a several hours of research.
    I am on contract with General Electric to develop a UI Style Guide for an international team of developers. My client wants to be able to distribute the Style Guide as a PDF document, but needs to provide links to specific topics when submitting a "Story" in an Agile development environment to the programmers.
    Ideally, I would like to be able to create "named destinations" in InDesign such that I can provide the client with a list of URLs similar to this format:
    file:\\StyleGuide\Test1-20131024a.pdf\#nameddest=AnchorText-01
    However, I can not figure out how to create "named destinations" in the PDF file from the InDesign file in which I have created the Anchor Text in the Hyperlinks tab.
    Alternately, the client would be satisfied with the ability to link to specific bookmarks in the exported PDF file that have been derived from the configuration of the Table of Contents styles, but my research has led me to believe that it is not possible to hyperlink from a browser window to a bookmark in a PDF file (only to specific page numbers, search word lists, named destinations, and comments) as described here: http://blogs.adobe.com/tcs/2011/01/tcs-specific/linking-to-a-page-within-a-pdf-and-more.ht ml
    Having been using InDesign since 1988, when it was PageMaker, I would prefer to use it to provide GE with the most attractive deliverable, but they are now leaning heavily toward having me licensed with Madcap Flare, which has this capability built in:
    http://webhelp.madcapsoftware.com/flare9/Default.htm#Nav_Links/Named_Destinations/Creating _Named_Destinations.htm
    Please help me to find a solution that will allow me to continue using InDesign for this project.
    Thank you!
    Lynne O’Connor
    Technical Writer (contractor)
    GE Oil & Gas - Measurement & Control

    Follow-up post (solution is not available):
    I have just completed a phone call with Gaurev Sethi of Adobe escalated technical support in which I shared my screen to explain and demonstrate the desire to link from an external URL to a specific location within a PDF file that has been exported from InDesign. After 40 minutes, during which I was placed on hold a few times while he consulted with his team, it was determined that the desired functionality is not supported in InDesign and has been identified as a limitation of the software.
    In researching alternate documentation software that supports PDF export, I discovered that Madcap Software supports this functionality in its Flare product:
    http://webhelp.madcapsoftware.com/flare9/Default.htm#Nav_Links/Named_Destinations/Creating _Named_Destinations.htm
    Note that linking via URL to a bookmarked location within a PDF is not supported:
    http://blogs.adobe.com/tcs/2011/01/tcs-specific/linking-to-a-page-within-a-pdf-and-more.ht ml
    More about parameters that can be specified to open PDF files are available here:
    http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
    Although the above link is for a previous version of Acrobat, I could find no evidence to the contrary in the current SDK documentation.
    -Lynne

  • Unable to open PDF output (PDF downloaded from Interactive Report--APEX)

    Hi,
    I'm getting below error while opening a PDF file downloaded from an interactive report (APEX).
    Adobe reader cound not open "TEST.pdf"because it is either not supportd file or because the file has been damaged.
    Thanks & Regards,
    Ramamuni.

    Steps of pdf Printing of Report from FOP:
    1) Download and unzip the following needed files in D:\Apex_fop directory.
    2) Open your command prompt .
    Change the directory to D:\Apex_fop\cocoon-2.1.11.
    Set the Java_Home environment variable as: set JAVA_HOME= C:\Program Files\Java\jdk1.5.0_21
    then type build war
    3) After getting the prompt back as D:>Apex_fop>cocoon-2.1.11>
    Copy coocon.war file from the folder D:\Apex_fop\cocoon-2.1.11\build\cocoon.
    Paste this file into webapps subdirectory in main tomcat directory having path as D:\APEX_FOP\apache-tomcat-6.0.26\webapps.....place it in the top
    level of webapps directory.
    4) Now just startup tomcat as D:>APEX_FOP>apache-tomcat-6.0.26>bin>startup.bat
    The cocoon.war file will automatically uncompressed as directory.
    5) To change the port of apache tomcat , edit apache-tomcat-6.0.26\conf\server.xml & change port attribute of Connector element from 8080 to 8181.
    Just check whether Tomcat is running or not as http://localhost:8181/
    & to check cocoon type http://localhost:8181/cocoon/
    6) Now copy fop_post directory & paste it undes new cocoon directory in webapps having path as D:\APEX_FOP\apache-tomcat-6.0.26\webapps
    \cocoon.
    7) Now you need to do some apex settings as follows:
    In APEX, just log in as ADMIN into apex/apex_admin and went to Instance Settings and did the following:
    - Print Serverr: Standard Support
    - Print Server Protocol: HTTP
    - Print Server Host Address:localhost
    - Print Server Port: 8181
    - Print Server Script: /cocoon/fop_post
    In your APEX application, in the Regions section, Click on the Print link next to your report and do the following settings:
    - Enable Report Printing: Yes
    - Link Label: Print
    - Response Header: Report Settings
    - View File As: Attachment
    - Output Format: PDF
    - Report Layout: Default Report Layout
    - Print URL: f?p=&APP_ID.:1:&SESSION.:FLOW_XMLP_OUTPUT_R1063230002781575
    8) Open up the Report Page and click Print , You will get the pdf report.
    I am sure this will help you
    Regards

  • How to generate multiple output pdf's from one oracle reports

    how to generate multiple output pdf's from one oracle reports.
    I have a report where I have to generate more than one output files from the same report based on a parameter.
    Each output file is for each parameter.
    Is this possible in oracle reports, is so how ?

    You can better post your question in the reports forum instead of this pl/sql forum.

  • Open PDF in browser - but cant control/close window from javascript

    Hi
    I hope I picked the correct forum
    Basically I have a site in asp classic. From a button I opens 2
    windows via javascript.
    One contains info, one shows a related file ( could be tiff or pdf ).
    When user closes info-window, I also close the file window via javascript, so that user only hav to click once.
    That works with tiff, but not with pdf, '!file.closed' returns that window are already closed.
    Somehow I simply loose contact to that window when I open pdf.
    My Adobe is set  with "open pdf in browser", version 10.1.2
    Any Ideas ?
    Overview what I do:
    function openTwoWindows(jnr,vikar,hvorfra){
              var left, top,vikar;
              width = (window.screen.availWidth/2)+80;
              width2 = (window.screen.availWidth/2)-80;
              height  = (window.screen.availHeight);
              info = window.open('info.asp'','top=0,left=0,height='+height+',width='+width+',resizable=yes,scr ollbars=yes,status=yes');
              var settings= 'toolbar=no,location=no,directories=no,'+
              'status=no,menubar=no,scrollbars=no,resizable=yes, top=0, left='+width+', height='+height+',width='+width2;
              file = window.open('showfile.asp?strJnr='+jnr+'&print=false','file',settings);
              info.focus();
    function closeFileWindow(){
                if(file && !file.closed){
                             file.close();
    if the file is a pdf -> showfile code in asp classic:
    Response.AddHeader "Content-Disposition","inline;filename=filename.pdf"
    Response.ContentType = "Application/pdf"
    'Response.Clear
    Response.Buffer = true
    // fetch file from database
    Response.BinaryWrite rsTmp("Fil")
    Response.Flush
    Response.End

    Read this:
    http://forums.adobe.com/thread/535609?tstart=0

  • Cannot open PDFs in browser in IE from Search Center

    [SYSTEM]
    SharePoint 2013 Enterprise, 2WFE, 2App, 1SQL
    [ISSUE]
    We have a problem with opening PDF files from search results in IE. I can open PDFs in the browser with Chrome and Firefox in all site collections as well as search results.  If using IE10, I can open PDFs in browser everywhere except
    the Search results page. Also, if I right click on a document in search results, and click "Open in new tab" or "Open in new window", then the pdf opens up in browser just fine. If I copy the URL and paste it into the address
    box, the document will also open in browser with no problem.
    The only way that the browser tries to open a pdf document in the client is when you click on the document directly in Search results. All other ways of opening the file yield the right result.
    We really need PDFs to open in browser in IE.  Please help. 
    [TROUBLESHOOTING DONE]
    I set the Web Application Browser File Handling to Permissive from Central Administration.
    I specified for files to open in the browser in Search Center preferences accessible from the bottom of the search results page.
    I verified that "application/pdf" is an AllowedInlineDownloadedMimeType
    The Office Web Apps settings were modified to open PDFs in the default PDF reader rather than OWA.

    Hi Jerry,
    Can you check the similar thread
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d554e88c-d72f-46b0-8b1a-2f2024fcb9c0/i-e-8-browser-wont-open-pdf-file-returned-from-sharepoint-2010-search?forum=sharepointadminprevious
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • Close Browser From PDF

    HI Guys,
    I created a pdf form when the user downloads it he can choose open, save, cancel. I'd like the form to close when the user clicks on the submit button. I found app.execMenuItem("Close") which works fine from a local copy but if the user open the form without saving it first, I get an error message: can't execute command from within an external window. So I guess I need some javascript in the form to close the browser. As the window is automaticly created when the user clicks on open, I can catch it. I have seen something about AVDOC but it looks like VB code.
    Thanks for your help

    Acrobat cannot close a browser from inside a PDF. What you will need to do it create a hostContainer that can communicate between the PDF and the HTML page the PDF is embedded in. You can then have the PDF issue a message to the HTML page hostContainer that will tell it to close itself.
    See the Doc.hostContainer section of the JavaScript for Acrobat API Reference for more information.

  • How to Create a Rich Dynamic Input and Output PDF to insert and get data into, from Database (MSSQL)

    HI ,
    I want to use Adobe LiveCycle Designer and Adobe LiveCycle Workbench features to create a Dynamic PDF form which can allow me to store data into database(MSSQL Server) and Can also provide me the Output PDF form with all the information which has been been filled in by the User in input form. Both Input and Output forms must be Dynamic. I am stuck in this process and Need Experts Advice on the Complete optimal process flow of the Adobe.
    Regards
    Ritesh Grover

    HI
    Go to the lay out of your screen and doublr click on the table control fields, you can get the Properties/Attribute of the screen or table control Fields
    Assing a Group GRP1 for all the fields i n the table control.
    in PBO
    if ok_code = 'INPUT'.
    LOOP AT SCREEN.
    IF screen-grp1 = 'GRP1'.
    screen-input = 1.
    modify screen.
    endif.
    ENDLOOP.
    elseif ok_code = 'OUTPUT'.
    LOOP AT SCREEN.
    if screen-grp1 = 'GRP1'.
    screen-input = 0.
    modify screen.
    endif.
    endloop.
    endif.
    Regards
    Ramchander Rao.K
    Edited by: Ramchander Krishnamraju on Aug 8, 2009 5:27 AM

  • Link in PDF not opening from within browser

    Hi,
    I have a PDF file with a link to a file share. it works perfctly if i open Adobe Reader and click on the link. However if i open the PDf in browser teh link does not work.
    Has anyone seen this before?
    The link is:
    The error is:
    Any suggestions are welcomed.
    Vivanne

    This will need to be a setting in Lotus Notes - for example - IBM developerWorks : Lotus : The IBM Tips Podca

  • How to open report in the browser from PL/SQL procedure

    Hi,
    I need to call the report (with destype = SCREEN) from the PL/SQL procedure and display in the browser.
    For Example: when I call P_call_report procedure in my Forms6i button or at sql*plus, the report output PDF/HTML should open in the Browser window.
    Iam Using IE, report6i, forms 6i, Oracle 8.1.7, Windows OS
    I tried using UTL_HTTP(' ') in a procedure. But when I execute the procedure at sql*plus it says Pl/sql procedure completed successfully message without opening report output in the browser window. If I copy the same url and paste it in the browser, it works.
    Please let me know if there is any solution.
    thanks alot.

    I guess event driven publishing may work. But Iam not sure about the opening of the browser from inside the procedure.

  • Data visibility problem in PDF file generated from R/3 system

    Hi all,
    We are converting the output of a Smartform into a PDF format. From this smart from, we receive data in OTF format, after which the required data is converted from OTF format to PDF format. Then PDF data is sent through mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1 as an attachment. 
    For the above mentioned Smartform, we have defined Paragraph & Character font type as 'TIMES' in smart style. But when we receive the PDF file (through mail), some data of appears in other fonts:
    1) When PDF file is generated from Development system, the different font types which are used by PDF are Arial and Times-Roman. In this case, we are able to see the PDF output and faced no major problems because both of these fonts are supported by PDF file format.
    2) When PDF file is generated from Testing system, the font types which is used by PDF is Arial. In this case, we are able to see the PDF output because this font is supported by PDF file format.
    3) When PDF file is generated from Production system, the different font types which are used by PDF are Arial, Times-Roman and PBRS. Here, we are able to see the data which is displayed in Arial font and Times-Roman font. But we are not able to see the data which is displayed in PBRS font because this type of font is not supported by PDF file format. If we copy the distorted text from PDF file and paste it in MS-Word then the required data is clearly visible and that is due to the reason that MS-Word supports PBRS font.
    But as per smart style we have used only 'TIMES' font, then why different fonts are appearing in PDF file?
    What settings are required to be done to make this data visible?
    Any pointer to solve this issue will be really appreciable. Thanks in advance for your help.
    Thanks and Regards,
    Dheeraj Tolani

    Hi,
    check the following
    http://help.sap.com/bp_biv235/BI_EN/html/bw.htm
    business content
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/g-i/how%20to%20co-pa%20extraction%203.0x
    https://websmp203.sap-ag.de/co
    http://help.sap.com/saphelp_nw04/helpdata/en/37/5fb13cd0500255e10000000a114084/frameset.htm
    (navigate with expand left nodes)
    also co-pa
    http://help.sap.com/saphelp_nw04/helpdata/en/53/c1143c26b8bc00e10000000a114084/frameset.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/fb07ab90-0201-0010-c489-d527d39cc0c6
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1910ab90-0201-0010-eea3-c4ac84080806
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ff61152b-0301-0010-849f-839fec3771f3
    FI-CO 'Data Extraction -Line Item Level-FI-CO'
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a7f2f294-0501-0010-11bb-80e0d67c3e4a
    FI-GL
    http://help.sap.com/saphelp_nw04/helpdata/en/c9/fe943b2bcbd11ee10000000a114084/frameset.htm
    http://help.sap.com/saphelp_470/helpdata/en/e1/8e51341a06084de10000009b38f83b/frameset.htm
    http://www.sapgenie.com/sapfunc/fi.htm
    Please reward for the same.

  • How to print PDF file content from ABAP in background?

    Hi,
    Is it possible to print PDF file content from ABAP in background?
    I have some PDF content which I need to print it, these PDF files are generated outside the SAP.
    Please have you any suggestions?
    Thank you
    Tomas

    <b><u>Solution:</u></b><br>
    <br>
    The target output device must support PDF print, this is only one limitation.<br>
    <br>
    REPORT  z_print_pdf.
    TYPE-POOLS: abap, srmgs.
    PARAMETERS: p_prnds LIKE tsp01-rqdest OBLIGATORY DEFAULT 'LOCL',
                p_fname TYPE file_table-filename OBLIGATORY LOWER CASE,
                p_ncopi TYPE rspocopies OBLIGATORY DEFAULT '1',
                p_immed AS CHECKBOX.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
      DATA: lv_rc     TYPE i,
            lv_filter TYPE string.
      DATA: lt_files TYPE filetable.
      FIELD-SYMBOLS: <fs_file> LIKE LINE OF lt_files.
      CONCATENATE 'PDF (*.pdf)|*.pdf|' cl_gui_frontend_services=>filetype_all INTO lv_filter.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          file_filter             = lv_filter
        CHANGING
          file_table              = lt_files
          rc                      = lv_rc
        EXCEPTIONS
          OTHERS                  = 1.
      IF sy-subrc NE 0 AND lv_rc EQ 0.
        MESSAGE 'Error' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      READ TABLE lt_files ASSIGNING <fs_file> INDEX 1.
      IF sy-subrc EQ 0.
        p_fname = <fs_file>-filename.
      ENDIF.
    AT SELECTION-SCREEN.
      DATA: lv_name   TYPE string,
            lv_result TYPE boolean.
      lv_name = p_fname.
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = lv_name
        RECEIVING
          result               = lv_result
        EXCEPTIONS
          OTHERS               = 1.
      IF sy-subrc NE 0.
        MESSAGE 'Bad file!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      IF lv_result NE abap_true.
        MESSAGE 'Bad file!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
    START-OF-SELECTION.
    END-OF-SELECTION.
      PERFORM process.
    FORM process.
      DATA: lv_name     TYPE string,
            lv_size     TYPE i,
            lv_data     TYPE xstring,
            lv_retcode  TYPE i.
      DATA: lt_file TYPE srmgs_bin_content.
      lv_name = p_fname.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename                = lv_name
          filetype                = 'BIN'
        IMPORTING
          filelength              = lv_size
        CHANGING
          data_tab                = lt_file
        EXCEPTIONS
          OTHERS                  = 1.
      IF sy-subrc NE 0.
        MESSAGE 'Read file error!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = lv_size
        IMPORTING
          buffer       = lv_data
        TABLES
          binary_tab   = lt_file
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc NE 0.
        MESSAGE 'Binary conversion error!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      PERFORM print USING p_prnds lv_data CHANGING lv_retcode.
      IF lv_retcode EQ 0.
        WRITE: / 'Print OK' COLOR COL_POSITIVE.
      ELSE.
        WRITE: / 'Print ERROR' COLOR COL_NEGATIVE.
      ENDIF.
    ENDFORM.                    " PROCESS
    FORM print USING    iv_prndst  TYPE rspopname
                        iv_content TYPE xstring
               CHANGING ev_retcode TYPE i.
      DATA: lv_handle    TYPE sy-tabix,
            lv_spoolid   TYPE rspoid,
            lv_partname  TYPE adspart,
            lv_globaldir TYPE text1024,
            lv_dstfile   TYPE text1024,
            lv_filesize  TYPE i,
            lv_pages     TYPE i.
      CLEAR: ev_retcode.
      CALL FUNCTION 'ADS_SR_OPEN'
        EXPORTING
          dest            = iv_prndst
          doctype         = 'ADSP'
          copies          = p_ncopi
          immediate_print = p_immed
          auto_delete     = 'X'
        IMPORTING
          handle          = lv_handle
          spoolid         = lv_spoolid
          partname        = lv_partname
        EXCEPTIONS
          OTHERS          = 1.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CALL FUNCTION 'ADS_GET_PATH'
        IMPORTING
          ads_path = lv_globaldir.
      CONCATENATE lv_globaldir '/' lv_partname '.pdf' INTO lv_dstfile.
      OPEN DATASET lv_dstfile FOR OUTPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      TRANSFER iv_content TO lv_dstfile.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CLOSE DATASET lv_dstfile.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CALL FUNCTION 'ZBAP_RM_PDF_GET_PAGES'
        EXPORTING
          iv_content = iv_content
        IMPORTING
          ev_pages   = lv_pages.
      lv_filesize = XSTRLEN( iv_content ).
      CALL FUNCTION 'ADS_SR_CONFIRM'
        EXPORTING
          handle   = lv_handle
          partname = lv_partname
          size     = lv_filesize
          pages    = lv_pages
          no_pdf   = ' '
        EXCEPTIONS
          OTHERS   = 1.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CALL FUNCTION 'ADS_SR_CLOSE'
        EXPORTING
          handle = lv_handle
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
    ENDFORM.                    " PRINT

Maybe you are looking for