To Display PDF from BSP

Hi,
Im calling a method in my BSP application which gives me PDF output.
CALL METHOD ref->******
  EXPORTING
    lv_vbeln      = lv_vbeln
  IMPORTING
   l_header      = l_header
   wa_head_right =
   message       =
   l_vbeln_text  =
   with_hold     =
   with_hold_n   =
   g_flag        =
   l_pricekey    =
     formout  = formoutput.
My formoutput-PDF has the xstring, and to call this PDF file i have written the below code
l_pdf_xstring = formoutput-pdf.
CREATE OBJECT cached_response TYPE cl_http_response
                        EXPORTING add_c_msg = 1.
data = l_pdf_xstring.
l_pdf_len1 = XSTRLEN( l_pdf_xstring ).
CALL METHOD cached_RESPONSE->SET_CONTENT_TYPE
  EXPORTING
    CONTENT_TYPE = 'application/pdf'.
cached_response->set_cdata( data   = data
                            length = l_pdf_len ).
CALL METHOD cached_response->if_http_response~set_status
  EXPORTING
    code   = 200
    reason = 'OK'.
CALL METHOD cached_response->if_http_response~server_cache_expire_rel
  EXPORTING
    expires_rel       = 180.
CALL FUNCTION 'GUID_CREATE'
  IMPORTING
    ev_guid_32 = guid.
v_guid = guid.
    call method cl_http_ext_csif=>access_info_get
      changing
        crep_http = lv_crep_http
      exceptions
        failed    = 1
        others    = 2.
    if lv_crep_http-http_port is not INITIAL.
      write lv_crep_http-http_port to lv_crep_http-http_port no-zero.
    else.
      write lv_crep_http-http_sport to lv_crep_http-http_sport no-zero.
    endif.
CONCATENATE runtime->application_url '/' v_guid '.pdf' INTO display_url.
cl_http_server=>server_cache_upload( url      = display_url
                                     response = cached_response ).
    if lv_crep_http-http_port is not INITIAL.
      concatenate 'http://' lv_crep_http-http_serv ':'
      lv_crep_http-http_port display_url into display_url.
    else.
      concatenate 'https://' lv_crep_http-http_serv ':'
      lv_crep_http-http_sport display_url into display_url.
    endif.
    data: lv_url1 type string.
    lv_url1 = display_url.
When I open the generated link, its giving that my PDF file is damaged or cannot be displayed. I have found the same code in many forums, its not working in this particular program. Please help me out with this.
Thanks in advance.

With the help of some other posts and blogs.. am able to display the pdf now.
However, the default magnification(zoom) is always 44.5%. Any ideas as to how this can be increased or set to a default value.
Sri

Similar Messages

  • Problem displaying PDF in BSP

    Hi All,
    With the help of Craigs Blog
    /people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
    I coded a BSP to display PDF from a spool number.
    I did everything mentioned in the blog. When i execute, the pdf gets displayed, however the data is some unconverted junk data. Can any one suggest what i am doing wrong here.
    Heres the coding in the Event handler (OnInputProcessing) :
    DATA: radioButtonGroup TYPE REF TO CL_HTMLB_RADIOBUTTONGROUP.
    DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.
    DATA: cached_response TYPE REF TO if_http_response.
    DATA: response TYPE REF TO if_http_response.
    DATA: guid TYPE guid_32.
    fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
                           request = request
                           id      = 'myUpload'
                           name    = 'fileUpload' ).
    file_name      = fileUpload->file_name.
    file_mime_type = fileUpload->file_content_type.
    file_length    = fileUpload->file_length.
    file_content   = fileUpload->file_content.
    radioButtonGroup ?= CL_HTMLB_MANAGER=>GET_DATA(
                           request = request
                           id      = 'display_type'
                           name    = 'radioButtonGroup' ).
    display_type = radioButtonGroup->selection.
    IF display_type = 'convertspool'.
      DATA: itab TYPE TLINE,
            witab TYPE TABLE OF TLINE,
            output TYPE STRING,
            outputx TYPE XSTRING.
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID              = 0002344365
          NO_DIALOG                = 'X'
        TABLES
          PDF                      = witab
        EXCEPTIONS
          ERR_NO_ABAP_SPOOLJOB     = 1
          ERR_NO_SPOOLJOB          = 2
          ERR_NO_PERMISSION        = 3
          ERR_CONV_NOT_POSSIBLE    = 4
          ERR_BAD_DESTDEVICE       = 5
          USER_CANCELLED           = 6
          ERR_SPOOLERROR           = 7
          ERR_TEMSEERROR           = 8
          ERR_BTCJOB_OPEN_FAILED   = 8
          ERR_BTCJOB_SUBMIT_FAILED = 9
          ERR_BTCJOB_CLOSE_FAILED  = 10
          others                   = 11.
      if sy-subrc EQ 0.
        LOOP AT witab INTO itab.
          CONCATENATE
            output
            itab-tdline
          INTO output.
        ENDLOOP.
    ****Convert the Character String to Binary String
        data: r_string  type string.
        data: R_XSTRING type xstring.
        call function 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            text   = output
          IMPORTING
            buffer = outputx.
        CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING
    add_c_msg = 1.
        l_pdf_len = xstrlen( outputx ).
        cached_response->set_data( data   = outputx
                            length = l_pdf_len ).
        cached_response->set_header_field( name  =
    if_http_header_fields=>content_type
                                           value = 'application/pdf' ).
        cached_response->set_status( code = 200 reason = 'OK' ).
        cached_response->server_cache_expire_rel( expires_rel = 180 ).
        CALL FUNCTION 'GUID_CREATE'
          IMPORTING
            ev_guid_32 = guid.
        CONCATENATE runtime->application_url '/' guid '.pdf' INTO
    display_url.
        cl_http_server=>server_cache_upload( url      = display_url
                                             response = cached_response ).
      ENDIF.
      RETURN.
    ENDIF.
    Regards
    Sri

    With the help of some other posts and blogs.. am able to display the pdf now.
    However, the default magnification(zoom) is always 44.5%. Any ideas as to how this can be increased or set to a default value.
    Sri

  • PDF from bsp application

    Dear All,
    I am new to this blog.
    I currently working on BSP's.  My requirement is like below.
    In my company portal, when an employee logins to portal under ESS tab,
    he can get Employee verification letter ( PDF ) from his manager under whom he is working.  This PDF he can print and get the signature from his manager.
    On first page he will have 3 questions ...
    1) Whether you want base salary in letter ( PDF )  . answer: Yes or No radio button
    2)  Whether you want ssn  number in letter ( PDF ) answer: Yes or No radio button
    similarly third quesion.
    When employee clicks on print preview button on the same page,  then he will get PDF form with follwing matter:
    Company  Name,
    addresses, Logo,
    Mr XXXXXXX is our employee since. His SSN no.......
    XYZZZZ
    Hr Manager,
    Pls let me know how to solve the above.
    I got an RFC for my BSP for getting employee details.  my question is how work on above in BSP.
    Regards,
    Kishan

    Hi Sharmila ,
    Thanks for reply.
    I tried with smart form.
    I created a smartform with only one text on smartform for just testing.
        i developed the BSP application .  when i press the butten "printpreview' on first page it should open PDF page with out put of smart form.
    the code is as below... but it is not working...it is not giving any result.. just remains in first page.
    generated result: PDF format
      data: l_pdf_xstring  type xstring,
            lt_lines       type table of tline,
            ls_line        type tline,
            l_pdf_len      type i.
      data: output_options      type ssfcompop,
            control_parameters  type ssfctrlop,
            output_data         type ssfcrescl,
            devtype             type rspoptype.
      data: lt_sys type table of mara.
      DATA: cached_response TYPE REF TO if_http_response.
      DATA: guid TYPE guid_32.
    data : runtime type c.
      DATA : display_url type string.
    DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.
      control_parameters-langu = sy-langu.
      control_parameters-no_dialog = 'X'.
      control_parameters-getotf    = 'X'.
      select * from mara into table lt_sys.
      call function 'SSF_GET_DEVICE_TYPE'
        EXPORTING
          i_language             = sy-langu
        IMPORTING
          e_devtype              = devtype
        EXCEPTIONS
          no_language            = 1
          language_not_installed = 2
          no_devtype_found       = 3
          system_error           = 4
          others                 = 5.
    set device type in output options
      output_options-tdprinter = devtype.
      CALL FUNCTION '/1BCDWB/SF00000010'
        EXPORTING
         CONTROL_PARAMETERS         = control_parameters
         OUTPUT_OPTIONS             = output_options
         USER_SETTINGS              = space
         ZTRNO                      = '5657'
       IMPORTING
         JOB_OUTPUT_INFO            = output_data
       EXCEPTIONS
         FORMATTING_ERROR           = 1
         INTERNAL_ERROR             = 2
         SEND_ERROR                 = 3
         USER_CANCELED              = 4
         OTHERS                     = 5
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      call function 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_filesize          = l_pdf_len
          bin_file              = l_pdf_xstring
        TABLES
          OTF                   = OUTPUT_DATA-OTFDATA
          LINES                 = LT_LINES
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          others                = 5.
      if sy-subrc EQ 0.
        CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
        l_pdf_len = xstrlen( l_pdf_xstring ).
        cached_response->set_data( data   = l_pdf_xstring
                            length = l_pdf_len ).
        cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                           value = 'application/pdf' ).
        cached_response->set_status( code = 200 reason = 'OK' ).
        cached_response->server_cache_expire_rel( expires_rel = 180 ).
        CALL FUNCTION 'GUID_CREATE'
          IMPORTING
            ev_guid_32 = guid.
        CONCATENATE  'runtime->application_url' '/' guid '.pdf' INTO display_url.
        cl_http_server=>server_cache_upload( url      = display_url
                                             response = cached_response ).
      ENDIF.
      RETURN.

  • Cannot Display PDF from Documentum in SAP

    Hello Everyone,
    We have linked SAP with Documentum to be able to retrieve documents stored in the content server. We made all the setting required in OAC0, OAC2, OAC3. But when we are posting a document against a Purchase Order from documentum and trying to view that PDF from "ME23" it is giving us an error message as shown below:-
    "The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    An invalid character was found in text content. Error processing resource 'file:///C:/Documents and Settings/gopal.yarlagad...
    But if we go into the "OAOR" I can see the document against the Purchase order. We are not able to figure out the issue regarding this. I would greatly appreciate your help if you can help me in resolving this issue.
    Regards,
    Gopal.

    We also had the same issue. It was working prior, and suddenly we can't view .msg file (in CMOD archived storage) in portal as it no longer recognize mime type for this. This must be a new patch from outlook last week. We ended up implementing config change suggested in note 1840170, and add this mime entry in local registry. As per IBM note http://www-01.ibm.com/support/docview.wss?uid=swg21610741, it looks like there's no other choice but to do it.
    We plan to push this entry to all users' computers soon. 
    Regards.

  • Display PDF from flex windows application

    Hi,
    I am creating a flex windows application using action script and mxml script.I need help in displaying a PDF document in that windows application from a netwrok drive or local pc.I tried google search it is giving me some open source projects with IFrames.But,they can be only used for browser applications(web).So,anyone please suggest me how could i accomplish this task with winows application.
    Thanks,
    adi2010

    Hi ,
    The solution for the thread is
    <mx:HTML id="pdfHtml" location="test.html" width="100%" height="100%" />
    var pdfFile:File = File.applicationDirectory.resolvePath(pdfHtml.location);
        pdfFile = new File(pdfFile.nativePath);
        var fileURL:String = pdfFile.url;
        pdfHtml.location = fileURL;
    Thanks,
    adi2010.

  • Reader 9.4.6 bug displaying PDFs from Autocad

    I've received several architectural drawings produced from Autocad as PDFs. All of them display correctly in Reader 9.4.6 for Windows, but in Reader 9.4.6 for Unix, some dashed lines are missing from the PDFs when viewed on the screen or printed.
    When I look at the document properties in Adobe Reader, it shows PDF producer as "Acrobat Distiller 7.0.5 (Windows)", and PDF version as "1.4 (Acrobat 5.x).

    - If you about>plug-ins says Adobe Reader, that's what you have (and not Acrobat which unlike Reader is a paid program)
    - Reader X provides certain commenting tools. You should be able to add comments and highlight text using commenting tool
         - Reader 9.4.6 does not have free commenting tools, there can be certain special PDFs where this is allowed but not generically
    - The paid product - Acrobat will let you comment any PDF as long as the author of the PDF has not applied security to the file disabing it
    - Both Reader 9.4.6 and 10 are free products from Adobe. As I note earlier in my reply, only Reader X has free commenting. Both Reader X and Reader 9 will let you view and PDFs and comments.
    - You can develop plug-ins for both Reader and Acrobat products using the free SDK. For Reader, you need to get a special certificate (available at small cost) that needs to be embedded in your plug-in.

  • Displaying pdf from file system in OA framework pages

    Hi,
    If anyone could help me with this I would be very grateful.
    We have a number of pdfs containing sensitive information, held on our Unix file system in directories not publicly available.
    I want to create an OA framework page which takes the name of a pdf as a parameter and displays the content of that pdf on the user's browser. I cannot simply do a redirect because the pdfs are not publicly available.
    I've found some sample java code that allows you to set InputStream and OutputStream and read the content of the file. However, I cannot see how to redirect the output stream to the browser. Of course, this may be entirely the wrong approach.
    Can anyone suggest anything or point me to some documentation that might help?
    Many thanks,
    Mike Thorn.

    Hi Shiv,
    Thanks for responding. I'm not sure whether I've explained my problem properly, so I've included a code snipet below.
    I've got my head around how to stream the contents of a file to an output string but cannot see how to bolt this into the controller region for an OA framework page. In the code below, you'll see I have a dofile which reads from my D: drive and streams to the System.out. I'm calling this from the processRequest for the page controller but do not understand how to get the output stream into the OAHTMLWebBean (my inclusion of Google works just fine).
    All this Java is rather new to me I'm afraid.
    public static void dofile()
    try{
    OutputStream outStream = System.out;
    String fileName= (String)"index.htm";
    String filePath = "D:\\Jdeveloper\\jdevdoc\\";
    File f = new File(filePath, fileName);
    String fileType = fileName.substring(fileName.indexOf(".")+1,fileName.length());
    byte[] buf = new byte[8192];
    FileInputStream inStream = new FileInputStream(f);
    int sizeRead = 0;
    while ((sizeRead = inStream.read(buf, 0, buf.length)) > 0) {
    outStream.write(buf, 0, sizeRead);
    inStream.close();
    outStream.close();
         catch (Exception e) {
              System.err.println(e);
              System.err.println("dofile error");
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    dofile(); //but how do I egt the output to the OAHTMLWebBean?
    // the following works fine to include Google
    OAHTMLWebBean outRegion = (OAHTMLWebBean)createWebBean(pageContext, HTML_WEB_BEAN, null, "IFRAME");
    outRegion.setHTMLAttributeValue("src","http://www.google.co.uk");
    outRegion.setHTMLAttributeValue("width", "100%");
    outRegion.setHTMLAttributeValue("height", "60%");
    outRegion.setHTMLAttributeValue("title","My title");
    outRegion.setHTMLAttributeValue("name", "My name");
    pageContext.getPageLayoutBean().addIndexedChild(outRegion);
    Many thanks again for any help you can offer this Java virgin,
    Mike Thorn

  • Display PDF from cfhttp

    Hey everyone. I am trying to display a PDF I receive from
    <cfhttp> with the following line of code:
    <cfhttp method="get" getasbinary="yes" url="#theURL#">
    I want to be able to display the PDF within the page as
    opposed to just having a 'save as' box come up. I played with
    <cfcontent> but couldn't get it to do what I want. Any help
    is appreciated.

    Please help me by providing solution........It is Urgent
    Thanks!
    Srinivas

  • Adobe Reader plugin forbids displaying PDFs from outside domains

    One part of web application is local digital signing  using activex component. But I want to display a PDF that gets signed  beforehand and after. Since documents can be quite large I would'n  really want uploading them and then again downloading for displaying.
    Therefore I wanted to embed a PDF using local path (eg. file:///) but Adobe throws "Access denied" error. I tried lowering Reader's security settings to minimum but it didn't help.
    Is there any way to embed a PDF with source ouside of the web application domain?

    Solved it. Problem seemed to have been a crashed Acrobat process. Just kill all Acrobat tasks in the task manager, reload the link in the browser and the Save button now works.

  • Display PDF from BAPI in Webdynpro

    Hi all,
    I have a BAPI that returns a PDF file as a TLINE table, and I need to display the result in a Java Webdynpro, do you guys know how I can do that? Thank you in advance.

    Hello SAPer
    The TLINE table is not basically a PDF file but an OTF file. I suggest you to call one more BAPI 'Convert_OTF' that takes this TLINE table as input and returns a pdf_file.
    Then in JAVA Web Dynpro, use the following code in your action handler after calling the respective RFC :-
    byte[] pdfContent;
    String pdfFileName = null;
    pdfContent = wdContext.current<Bapi_name_OutputElement>().getE_Pdf_File();
    pdfFileName = "<name>"
    IWDCachedWebResource pdfResource= WDWebResource.getWebResource(pdfContent,WDWebResourceType.PDF);                                         
    try
    wdComponentAPI.getWindowManager().createExternalWindow(pdfResource.getURL(),pdfFileName,true).open();
    } catch (WDURLException e)
    msgMgr.reportException(e.getMessage(),false);
    I hope this helps you.
    Regards
    Kapil.

  • Display PDF from BAPI's binary output

    Dear All,
    I am struck badly with this scenerio here.
    we have a Bapi which is generating an adobe form in the backend and providing that as an attribute of type binary.
    i used the following code to display that binary output, to be opened in Acrobet reader.
    byte[] pdfContent= wdContext.nodeZhra_Get_Lettertype_Desc_Input().nodeOutput().currentOutputElement().getE_Bin_File();
         IWDCachedWebResource pdfResource = WDWebResource.getWebResource(pdfContent,WDWebResourceType.PDF);
         IWDWindow win = wdComponentAPI.getWindowManager().createExternalWindow(pdfResource.getURL(),"PDF in Arabic",true);
         win.setTitle("PDF in Arabic");
         win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
         win.removeWindowFeature(WDWindowFeature.TOOL_BAR);
         win.removeWindowFeature(WDWindowFeature.MENU_BAR);
         win.removeWindowFeature(WDWindowFeature.STATUS_BAR);
         win.show();
    the problem is that the acrobet reader opens and says it could not display the file and it may be not supported or might be damaged.BUT
    1. the file is being generated and correctly displayed on another system
    2. both systems have the same version and updates of acrober reader 9.
    Kindly let me know the solution or some work-around to solve this problem. Is there a way,where i should use interactive form to do this...
    thanks in advance

    Hello!
    If it works on one client but not on the other i think it is not a Server problem.
    Check th following:
    Open the document in the Browser where it is displayed and save it on a thumbdrive and open it on the other client.
    -> If it works: it must be Browser settings
    -> If not: the generated PDF is not valid for the Adobe Reader of the other client.
    If it works on the Server but not on the client, try to dump it to a file on the Webserver to see if the BAPI call (RFC/WS) is the problem. When you use XString for exampe I think there is a problem with the data beeing split into several lines. If you have the file you should be able to open it. Compare the size of the File on the WebAS and the backend.
    Kind regards
    Matthias
    Edited by: Matthias Schneider on Nov 4, 2008 6:19 PM

  • PDF download from BSP application

    hi all,
    With the bellow code i am able to download to PDF from BSP application
    Issue is when i click on the download button waiting popup window is not disappearing even after PDF displayed.
    Please help me to resolve how to stop this waiting popup window.
    response->delete_header_field( name = 'Cache-Control' ).  "#EC NOTEXT
      response->delete_header_field( name = 'Expires' ).        "#EC NOTEXT
      response->delete_header_field( name = 'Pragma' ).         "#EC NOTEXT
    Deactivated because of Note 904314 and Kompression in Kernel
      response->set_compression( options = '4' ).
      response->set_header_field( name  = 'content-type'
                                  value = 'application/pdf' ).
      response->set_header_field(
                         name  = 'cache-control'
                         value = 'max-age=0' ).
        response->set_header_field(
                           name  = 'content-disposition'
                           value = 'attachment; filename=candidate.pdf' ).
      l_pdf_len = XSTRLEN( l_pdf_xstring ).
      response->set_data( data   = l_pdf_xstring
                          length = l_pdf_len ).
      navigation->response_complete( ).
    Any help on this is highly appreciated.
    Thanks,
    Ravi

    May be you can navigate to another page AFTER the response_complete() method and show the message that 'PDF is downloaded successfully'
    or something meanful message. so that it will get a response back from server and 'wait...Processing' message might disappear.
    I'm not sure and didnt try..may be you can give it a try and let us know..
    navigation->response_complete( ).
    navigation->goto_page(....)

  • PDF file gets corrupted when generated from BSP

    Hi,
         I am generating a PDF file from a BSP page ( see the code below). The problem is that PDF file gets corrupted and  I am unable to open it. I also tried to use other functions like GUI_Download and DOwnload as suggested by many and they also do not work either. Has any one generated a PDF from BSP and can some one help?
    Data: GG type String.
    event handler for data retrieval
    data : event type ref to cl_htmlb_event.
    class cl_htmlb_manager definition load.
    class CL_HTTP_RESPONSE DEFINITION LOAD.
    DATA : PARAMS TYPE PRI_PARAMS,
             VALID  TYPE C,
    GV_SUCCESS_SPOOL_NO LIKE SY-SPONO.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING DESTINATION           = 'LOCL'
               COPIES                = COUNT
               LIST_NAME             = 'TEST'
               LIST_TEXT             = 'Test NEW-PAGE PRINT ON'
                  IMMEDIATELY           = ''
                  RELEASE               = 'X'
                  NEW_LIST_ID           = 'X'
               EXPIRATION            = DAYS
                  LINE_SIZE             = 140
               LINE_COUNT            = 23
               LAYOUT                = 'X_PAPER'
               SAP_COVER_PAGE        = 'X'
               RECEIVER              = 'SAP*'
               DEPARTMENT            = 'System'
                  NO_DIALOG             = 'X'
        IMPORTING OUT_PARAMETERS        = PARAMS
                  VALID                 = VALID.
      IF VALID <> SPACE.
        NEW-PAGE PRINT ON  PARAMETERS PARAMS NO DIALOG.
    write :/ 'Hello Message1'.
    write :/ 'Hello Message2 '.
    NEW-PAGE PRINT OFF .
      ENDIF.
    data :        spool_no TYPE TSP01-RQIDENT .
    spool_no = sy-spono.
    DATA: itab TYPE TLINE,
            witab TYPE TABLE OF TLINE,
            output TYPE STRING,
            outputx TYPE XSTRING.
    data : l_pdf_len type i.
    data: mi_bytecount type i.
    DATA : APP_TYPE TYPE STRING VALUE  'APPLICATION/PDF' .
    DATA:    cached_response TYPE ref to if_HTTP_RESPONSE.
    data : l_display_url type string .
    data : guid type GUID_32 .
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID              = spool_no
          NO_DIALOG                = 'X'
       IMPORTING
          PDF_BYTECOUNT            =  mi_bytecount
        TABLES
          PDF                      = witab
        EXCEPTIONS
          ERR_NO_ABAP_SPOOLJOB     = 1
          ERR_NO_SPOOLJOB          = 2
          ERR_NO_PERMISSION        = 3
          ERR_CONV_NOT_POSSIBLE    = 4
          ERR_BAD_DESTDEVICE       = 5
          USER_CANCELLED           = 6
          ERR_SPOOLERROR           = 7
          ERR_TEMSEERROR           = 8
          ERR_BTCJOB_OPEN_FAILED   = 8
          ERR_BTCJOB_SUBMIT_FAILED = 9
          ERR_BTCJOB_CLOSE_FAILED  = 10
          others                   = 11.
      if sy-subrc EQ 0.
        LOOP AT witab INTO itab.
          CONCATENATE
            output
            itab-tdline
          INTO output in character mode.
        ENDLOOP.
    endif.
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
            EXPORTING
                text   = output
                mimetype =   'APPLICATION/PDF'
            IMPORTING
                buffer = outputx.
    concatenate cl_abap_char_utilities=>byte_order_mark_little
    outputx
    into outputx in byte mode.
      response->set_header_field( name = 'content-type' value =
    'APPLICATION/PDF; charset=utf-16le'  ).
      response->delete_header_field( name =
    if_http_header_fields=>cache_control ).
      response->delete_header_field( name = if_http_header_fields=>expires
      response->delete_header_field( name = if_http_header_fields=>pragma )
      response->set_header_field( name = 'content-disposition'
                                  value = 'attachment; filename = TEST.PDF'
      l_PDF_len = xstrlen( OUTPUTX ).
      response->set_data( data = OUTPUTx
                          length = l_PDF_len ).
    navigation->response_complete( ).
    Regards
    Amit Agrawal

    HI Craig Cmehil,
                   I have tried this code as well as given in the URL specified by you. But using this also browser shows the following  content. It seems that PDF content is corrupted.
    My Output as shown on Browser Starts below this line----
    DF-1.3
    %âãÏÓ
    2 0 obj
    /WinAnsiEncoding
    endobj
    3 0 obj
    <<
    /Type /Font
    /Subtype /Type1
    /BaseFont /Courier
    /Name /F001
    /Encodg 2 0 R
    >>
    endobj
    4 0 obj
    <<
    /Length 5 0 R
    >>
    stream
    /F001 7.30 Tf 0 0 0.753 rg BT 18.00 570.65 Td 0 Tw <33302E30362E3230302020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020>Tj ET 0 0 0.753 rg BT 2950 570.65 Td 0 Tw
    <20204854545020436F6E74726F6C202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020>Tj ET 0 0 0.753 rg BT 572.40 570.65 Td 0 Tw <2020202020202020202020202031>Tj ET q 0 0 0 RG 0.55 w 18.00 562.90 m
    634. 562.90 l S Q 0 0 0.753 rg BT 18.00 551.45 Td 0 Tw <48656C6C6F20416D6974>Tj ET 0 0 0.753 rg BT 18.00 541.85 Td 0 Tw <48656C6C6F204765726176>Tj ET
    endstream
    endobj
    5 0 obj
    624
    endobj
    6 0 obj
    <<
    /Type /Page
    /MediaBox
    /Parent 1 0 R
    /Resource
    <<
    /ProcSet
    /PDF /Text
    /Font
    <<
    /F001 3 0 R
    >>
    /XObject
    <<
    >>
    >>
    /Contents 4 0 R
    >>
    endobj
    7 0 obj
    <<
    /Author (AMG )
    /CreationDate (20050630 181301)
    /Creator (Form X_58_170 EN)
    /Producer (SAP R/3 Release 620 )
    %SAPinfoStart TOA_DARA
    %FUNCTI=(    )
    %MANDANT=(   )
    %DEL_DATE=(00000000)
    %SAP_OBJECT=(          )
    %AR_OBJECT=(          )
    %OBJECT_ID=(                          )
    %FORM_ID=(                                        )
    %FORMARCHIV=(  )
    %RESERVE=(   )
    %NOTIZ=(                                                                )
    %SAPinfoEnd TOA_DARA
    >>
    endobj
    1 0 obj
    <<
    /Type /Pages
    /Kids
    [ 6 0 R
    /Count 1
    >>
    endobj
    8 0 obj<<
    /Type /Catalog
    /Pages 1 0 R
    /PageMode /UseNone
    >>
    endobj
    xref
    0 9
    0000000000 65535 f
    0000001801 00000 n
    0000000017 0000n
    0000000052 00000 n
    0000000157 00000 n
    0000000840 00000 n
    0000000862 00000 n
    0000001048 00000 n
    0000001869 00000 n
    trailer
    /Size 9
    /Root 8 0 R
    /Info 7 0 R
    >>
    startxref
    1944
    %%EOF
    Browser Displey Content Ends----
    My Coding Starts----
    Data: GG type String.
    event handler for data retrieval
    data : event type ref to cl_htmlb_event.
    class cl_htmlb_manager definition load.
    class CL_HTTP_RESPONSE DEFINITION LOAD.
    DATA : PARAMS TYPE PRI_PARAMS,
             VALID  TYPE C,
    GV_SUCCESS_SPOOL_NO LIKE SY-SPONO.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING DESTINATION           = 'LOCL'
               COPIES                = COUNT
               LIST_NAME             = 'TEST'
               LIST_TEXT             = 'Test NEW-PAGE PRINT ON'
                  IMMEDIATELY           = ''
                  RELEASE               = 'X'
                  NEW_LIST_ID           = 'X'
               EXPIRATION            = DAYS
                  LINE_SIZE             = 140
               LINE_COUNT            = 23
               LAYOUT                = 'X_PAPER'
               SAP_COVER_PAGE        = 'X'
               RECEIVER              = 'SAP*'
               DEPARTMENT            = 'System'
                  NO_DIALOG             = 'X'
        IMPORTING OUT_PARAMETERS        = PARAMS
                  VALID                 = VALID.
      IF VALID <> SPACE.
        NEW-PAGE PRINT ON  PARAMETERS PARAMS NO DIALOG.
    write :/ 'Hello Amit'.
    write :/ 'Hello Gaurav '.
    NEW-PAGE PRINT OFF .
      ENDIF.
    GV_SUCCESS_SPOOL_NO = sy-spono.
    data :        spool_no TYPE TSP01-RQIDENT .
    spool_no = sy-spono.
    write: GV_SUCCESS_SPOOL_NO.
    *write: spool_no.
    IF display_type = 'convertspool'.
      DATA: itab TYPE TLINE,
            witab TYPE TABLE OF TLINE,
            output TYPE STRING,
            outputx TYPE XSTRING.
    data : l_pdf_len type i.
    data: mi_bytecount type i.
    DATA : APP_TYPE TYPE STRING VALUE  'APPLICATION/PDF' .
    DATA:    cached_response TYPE ref to if_HTTP_RESPONSE.
    data : l_display_url type string .
    data : guid type GUID_32 .
           spool_no like TSP01-RQIDENT .
    *spool_no = GV_SUCCESS_SPOOL_NO .
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID              = spool_no
          NO_DIALOG                = 'X'
       IMPORTING
          PDF_BYTECOUNT            =  mi_bytecount
        TABLES
          PDF                      = witab
        EXCEPTIONS
          ERR_NO_ABAP_SPOOLJOB     = 1
          ERR_NO_SPOOLJOB          = 2
          ERR_NO_PERMISSION        = 3
          ERR_CONV_NOT_POSSIBLE    = 4
          ERR_BAD_DESTDEVICE       = 5
          USER_CANCELLED           = 6
          ERR_SPOOLERROR           = 7
          ERR_TEMSEERROR           = 8
          ERR_BTCJOB_OPEN_FAILED   = 8
          ERR_BTCJOB_SUBMIT_FAILED = 9
          ERR_BTCJOB_CLOSE_FAILED  = 10
          others                   = 11.
      if sy-subrc EQ 0.
        LOOP AT witab INTO itab.
          CONCATENATE
            output
            itab-tdline
          INTO output in character mode.
        ENDLOOP.
    endif.
    *write : output.
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
            EXPORTING
                text   = output
                mimetype =   'APPLICATION/PDF'
            IMPORTING
                buffer = outputx.
    *concatenate cl_abap_char_utilities=>byte_order_mark_little
    *outputx
    *into outputx in byte mode.
    CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
    some Browsers have caching problems when loading Excel Format
      response->set_header_field( name = 'content-type' value =
    'APPLICATION/PDF'  ).
      response->delete_header_field( name =
    if_http_header_fields=>cache_control ).
      response->delete_header_field( name = if_http_header_fields=>expires
      response->delete_header_field( name = if_http_header_fields=>pragma )
        l_pdf_len = xstrlen( outputx ).
        cached_response->set_data( data   = outputx
                            length = l_pdf_len ).
        cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                           value = 'application/pdf' ).
        cached_response->set_status( code = 200 reason = 'OK' ).
        cached_response->server_cache_expire_rel( expires_rel = 180 ).
        CALL FUNCTION 'GUID_CREATE'
          IMPORTING
            ev_guid_32 = guid.
        CONCATENATE runtime->application_url '/' guid '.pdf' INTO l_display_url.
        cl_http_server=>server_cache_upload( url      = l_display_url
                                             response = cached_response ).
    RETURN.
    My Coding Ends----
    Any Further help on this.
    Regards
    Amit Agrawal

  • How to print specific pages of a pdf from a vb 2013 program using a print dialog

    Hi.  I am using the acrobat sdk to display pdfs from within a vb 2013 program, because the pdfs are large and we have developed indexes on certain columns.  The indexes are stored in SQL tables.  My program has a search window which allows the user to search for a value and displays all the pages on which this value appears in the indexed column in a listbox.  By double-clicking on the desired value in the listbox, the user can go to the selected page and column.  However, the user also needs to be able to highlight one or more of the pages in the listbox and print these pages.  I could do this silently using AcroExchAVDoc.PrintPages, but the user also needs to have a print dialog displayed in order to possibly select a watermark to be printed on the pages.  I also need to default the orientation of the pages depending on the document.
    I have reviewed the sdk documentation and also searched in Google and on this site but have not found a way to do this.  Does anyone have a suggestion?  Thanks for any help you can provide.
    Mary

    Hi.
    I did try using the printParams feature and it worked, but since I need to be able to print sets of non-consecutive pages,  I end up having to bring up the print dialogue multiple times and have the user set watermarks each time. 
    I decided to just create a new pdf in a temp directory containing the selected pages and open this document in a new window.  This works well and allows them to use the print button on the window to print, bringing up the print dialogue just once.  However, since I need to open the document in a way that shows the print button, I am using OpenInWindowEx, with AV_DOC_VIEW, and the option PDUseBookmarks or PDUseThumbs, rather than PDUseNone.  This displays a toolbar which also includes icons for creating a new pdf, deleting pages, etc.  I do not really want to include these icons on the toolbar.  Is there a way to remove unwanted icons from the toolbar, or make them invisible?
    Hope this makes sense.  Thanks for your help.
    Mary

  • Problem with pdf display downloaded from application server

    Hi all,
    I have a problem with displaying pdf downloaded from application server (saved in BINARY MODE).
    I am getting the pdf output of adobe form in FPFORMOUTPUT-PDF as rawstring back to my program and then converting that rawstring into binary form using the function module SCMS_BINARY_TO_STRING.
    Now, when I export the data to presentation server directly using cl_gui_frontend_services=>gui_download, the pdf is downloaded properly.
    However, when I save the data to application server file by looping at the internal table obtained from SCMS_XSTRING_TO_BINARY and using TRANSFER, and subsequently downloading the file in "unconverted format" from AL11 to my desktop, I am getting a "blank" pdf file (with the same number of pages as the one downloaded using gui_download).
    I have tried different encodings during download but in those cases i get corrupted pdf message. only the default option of INTIAL value seems to work.
    I am forced to believe that there is a problem in my code which saves the data to app server but I cant find any solution that is logical. Any solution to this would be greatly appreciated.
    Regards,
    Sasi
    Edited by: Sasi Upadrasta on Sep 29, 2010 7:55 PM

    used a program to read the file from appl server and then downloading it to desktop.

Maybe you are looking for

  • Stuck on version 2.4 software - 1st Generation Apple TV

    I have just completed a factory reset and am now stuck on version 2.4 software. Is there something else that I need to do to upgrade to the latest version available for a 1st generation Apple TV?

  • Account logged In but can't remember the Password

    The tittle sums it up, my boss has a skype account and has been logged for 1 year in that computer and forgot her password, now shee need to change computer and doesn't remember the password (not even the user)... so it's there a way to see the passw

  • I am unable to sync my music from iphone to mac, why?

    When I connect my ipone to my mac in order to sync, it does appear as a button in the navigation menu; However I've been able to successfullz sync photos, but NOT Music

  • Where do I get an English Sherlock?

    Oddly, my Sherlock 3 channels appear to be in German. But I do not speak German, and German was never defined as a chosen language on my computer. How do I get the Sherlock channels in English, like it used to be on Sherlock 2?

  • I can only print from one USB port - is this a problem

    Hi I am a recent convert from PC to Mac, with a new Intel-based MacBook. I have installed my Epson Stylus D68 Photo and have been successfully printing (eventually!). However, after recently unplugging the printer to move the laptop and then reconnec