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.

Similar Messages

  • 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

  • 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 INTERACTIVE FORM INTO WEBDYNPRO

    I'd like to display a pdf into a popup... it opens the popup it shows the pdf border but pdf is empty!!! Only template...
    Is anything wrong in the code bellow ?
    method DISPLAY_PDF .
      DATA : l_plvar type plvar.
      select single gsval
          from T77s0
          INTO l_plvar
          where grpid = 'PLOGI' AND
                SEMID = 'PLOGI'.
        DATA : L_SOBJID TYPE SOBJID.
      L_SOBJID = IM_STELL.
      DATA: FP_DOCPARAMS TYPE SFPDOCPARAMS.
      DATA: FP_FORMOUTPUT TYPE FPFORMOUTPUT.
      DATA : IE_OUTPUTPARAMS TYPE SFPOUTPUTPARAMS,
             I_NAME TYPE FPNAME,
             I_FUNCNAME TYPE FUNCNAME.
      DATA: GT_RESULT_ORG_TAB     TYPE TABLE OF SWHACTOR,
            GT_RESULT_ORG_OBJEC   TYPE  Z_T_RESULOBJ,
            GT_RESULT_REQUIREMENT TYPE  Z_T_RESULTREQ,
            GT_RESULT_DESCRIPTION TYPE  Z_T_RESULTDESC,
            GT_RESULT_DESCR_PDF   TYPE  ZTRESULTDESC,
            GT_RESULT_TXT_OBJEC   TYPE STANDARD TABLE OF T777O.
    IE_OUTPUTPARAMS-NODIALOG = 'X'.
    IE_OUTPUTPARAMS-GETPDF = 'X'.
      CALL FUNCTION 'FP_JOB_OPEN'
        CHANGING
          IE_OUTPUTPARAMS = IE_OUTPUTPARAMS
        EXCEPTIONS
          CANCEL
          USAGE_ERROR
          SYSTEM_ERROR
          INTERNAL_ERROR.
      IF SY-SUBRC NE 0.
        EXIT.
      ENDIF.
      TRY.
          I_NAME = 'ZHAP_PDF_JOB_DESCRIPTION_FORM'.
          CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
            EXPORTING
              I_NAME     = I_NAME
            IMPORTING
              E_FUNCNAME = I_FUNCNAME.
        CATCH CX_FP_API_REPOSITORY.
        CATCH CX_FP_API_USAGE.
        CATCH CX_FP_API_INTERNAL.
      ENDTRY.
      CALL FUNCTION 'ZHRTGMT_GET_JOB_DESCRIPTION'
        EXPORTING
          IP_PLVAR           = L_PLVAR
          IP_JOBID           = L_SOBJID
          IP_BEGDA           = SY-DATUM
          IP_ENDDA           = SY-DATUM
        IMPORTING
          RESULT_ORG_TAB     = GT_RESULT_ORG_TAB
          RESULT_ORG_OBJEC   = GT_RESULT_ORG_OBJEC
          RESULT_REQUIREMENT = GT_RESULT_REQUIREMENT
          RESULT_DESCRIPTION = GT_RESULT_DESCRIPTION
          RESULT_DESCR_PDF   = GT_RESULT_DESCR_PDF
        EXCEPTIONS
          NO_FOUND_REQ       = 1
          NO_ENTRY_DESC      = 2.
      CALL FUNCTION I_FUNCNAME
        EXPORTING
          /1BCDWB/DOCPARAMS     = FP_DOCPARAMS
          GT_RESULT_ORG_TAB     = GT_RESULT_ORG_TAB
          GT_RESULT_ORG_OBJEC   = GT_RESULT_ORG_OBJEC
          GT_RESULT_REQUIREMENT = GT_RESULT_REQUIREMENT
          GT_RESULT_DESCRIPTION = GT_RESULT_DESCRIPTION
          GT_RESULT_DESCR_PDF   = GT_RESULT_DESCR_PDF
        IMPORTING
          /1BCDWB/FORMOUTPUT    = FP_FORMOUTPUT
        EXCEPTIONS
          USAGE_ERROR           = 1
          SYSTEM_ERROR          = 2
          INTERNAL_ERROR        = 3.
      CALL FUNCTION 'FP_JOB_CLOSE'
        EXCEPTIONS
          USAGE_ERROR    = 1
          SYSTEM_ERROR   = 2
          INTERNAL_ERROR = 3
          OTHERS         = 4.
      DATA:
        NODE_PDF                            TYPE REF TO IF_WD_CONTEXT_NODE,
        ELEM_PDF                            TYPE REF TO IF_WD_CONTEXT_ELEMENT,
        STRU_PDF                            TYPE WD_THIS->ELEMENT_PDF .
    * navigate from <CONTEXT> to <PDF> via lead selection
      NODE_PDF = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_PDF ).
    * get element via lead selection
      ELEM_PDF = NODE_PDF->GET_ELEMENT(  ).
      CALL METHOD ELEM_PDF->SET_ATTRIBUTE
        EXPORTING
          NAME  = 'SOURCE'
          VALUE = FP_FORMOUTPUT-PDF.
      DATA : LR_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER,
             LT_TEXTS TYPE STRING_TABLE,
             LR_COMPONENT_API TYPE REF TO IF_WD_COMPONENT,
             LR_POPUP TYPE REF TO IF_WD_POPUP_TO_CONFIRM,
             LR_VIEW_CONTROLLER TYPE REF TO IF_WD_VIEW_CONTROLLER,
             LR_COMPCONTROLLER TYPE REF TO Ig_COMPONENTCONTROLLER,
             l_title type string.
      LR_COMPCONTROLLER = wd_THIS . "  get_Componentcontroller_ctr( ).
      LR_COMPONENT_API = wd_this->wd_get_api( ). "wd_comp_controller
      LR_WINDOW_MANAGER = LR_COMPONENT_API->get_window_manager( ).
      LR_COMPCONTROLLER->mr_window = LR_WINDOW_MANAGER->create_window( window_name = 'POPUP_PDF').
      LR_COMPCONTROLLER->mr_window->set_close_button( CLOSE_BUTTON = 'X' ).
      LR_COMPCONTROLLER->mr_window->SET_WINDOW_TITLE( SPACE ).
      LR_COMPCONTROLLER->mr_window->open( ).
    endmethod.

    I forgot to add that the method has been creeated in componentcontroller..

  • 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

  • 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

  • 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 into an abap webdynpro view: disable navigation

    Hello
    is it possible to disable the navigation panes and/or the toolbar and/or statusbar of acrobat reader inside your abap webdynpro application?
    When you specify for example #navbar=0 as parameter then you disable the navigation pane.
    Eg: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cfb80249-0801-0010-3eaa-829afeac170f#navpanes=0 and https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cfb80249-0801-0010-3eaa-829afeac170f
    Is it possible in an abap webdynpro with a interactive form element?
    Thanks
    Luc

    Hi Luc M,
    We can Disable the ToolBar of Interactive Form, this can be done by writing the Code in WDDOMODIFY Method of the respective View.
    Do add the Following the Lines of Code in the WDDOMODIFY Method
    DATA: LR_INTERACTIVE_FORM type ref to CL_WD_INTERACTIVE_FORM,
               LR_METHOD_HANDLER type ref to IF_WD_IACTIVE_FORM_METHOD_HNDL.
    LR_INTERACTIVE_FORM ?= VIEW->GET_ELEMENT( 'INTERACTIVE_FORM_UI_ELEMENT_NAME' ).
    LR_METHOD_HANDLER ?= LR_INTERACTIVE_FORM->_METHOD_HANDLER.
    LR_METHOD_HANDLER->set_hide_toolbars( abap_true ).
    ***With the above code you can only disable the ToolBar.
    Regards
    Pradeep Goli
    Edited by: Pradeep Goli on Mar 17, 2009 2:45 PM

  • 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 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

  • Saving and sending Adobe Form pdf from WebDynpro

    Hi,
    I'm developing an application which receives data from a RFC to a R/3. The datas are displayed on a pdf-Document in a Webdynpro. This works fine.
    Now I want to send this form as attachment in an email. Do I have to save it first as pdf or can I send it directly?
    On SapHelp I found a tutorial how to save a form as pdf:
    http://help.sap.com/saphelp_nw04/helpdata/en/dc/f1783fe3263042e10000000a114084/frameset.htm
    I tried out the describtion but without success. I defined an action on the view where the form should be displayed and added the coding in the implementation of the event. In the form I added a button Submit to SAP from the Web Dynpro Library. When I press the button, nothing happens. Do I have to make any changes under Object->Field->Control Type?
    Another question about the coding:
    public void onActionsubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionsubmit(ServerEvent)
              IPrivateResultView.IContextElement contextElement =
                   wdContext.currentContextElement();
              byte[] bytes = contextElement.getPdfSource();
              try {
                   File file = new File("C:
    temp
    example.pdf");
                   FileOutputStream os = new FileOutputStream(file);
                   os.write(bytes);
                   os.close();
              } catch (IOException e) {
                    // do something
                   e.printStackTrace();
              wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(
                   "You have pressed Submit!");
        //@@end
    The path where the pdf shall be saved is "C:
    temp
    example.pdf", I expected something like "C:\temp\example.pdf" on a windows machine.
    Where will the pdf be saved? On the machine i deployed the application (what about rights for saving) to or localy on the machine I start the app?
    Does anyone knows how to send the pdf by email when saving the form or knows a helpful tutorial?
    Many thanks for your help
    Mathias Lange

    Hi all,
    doing Tutorial 31 from SDN (Interactive Forms using E-Mail) I have a problem with the entries for the smtp-host in the coding.
    I always get the error message: 
    Sending failed;  nested exception is: com.sap.engine.services.javamail.exception.JavaMailMessagingException: Cannot send message to host xxx:25 using the SMTP protocol.
    //@@begin onActionSendForm(ServerEvent)
    Properties props = new Properties();
    String host = "xxx";
    props.put("mail.smtp.host", host);
    In host I entered the entrie for the smtp i use in Outlook, where it works fine. In the Tutorial i get the errormessage.
    I have an smtp-server from our company with which it works too, but it is not the smtp used by Outlook.
    And i can't use this smtp at my customers.
    Could it be a problem with the used ports or a needed authentication? In the Tutorial is no coding for this.
    Does anyone use a freemailer for this tutorial and have success with the smtp of this freemailer?
    Kind Regards
    Mathias
    Message was edited by: Mathias Lange

  • Display Smartform Pdf output in ABAP Webdynpro application

    Hello,
    there is a solution for displaying Smartform output in Java Webdynpro application in this forum. Since i want to start an project in ABAP Webdynpro i need a solution for this technology since i don't want to recreate all the paperwork again using Adobe. Is there any solution available?
    Thanks
    Udo Ahle

    Hello,
    this is the solution which i was able to implement using the hints given by Heidi and Thomas. Thank you for the support. With this solution it is possible to reuse oldstyle sapscripts and smartforms in todays environment.  Here is the sample code which solves the problem:
    In WDA you define for example a pushbutton to start the display of the PDF.
    In the onaction method you implement:
    method ONACTIONSHOW_PDF .
      data LX_pdf type xstring.
    * get PDF from existing sapscript or smatform
      call function 'Y_PDF_GET' destination '46c'
        IMPORTING
          ex_PDF = LX_PDF.
    * append the pdf to the response
      cl_wd_runtime_services=>attach_file_to_response(
        i_filename  = 'Hello.PDF'
        i_content   = lx_pdf
        i_mime_type = 'application/pdf'
        i_in_new_window = 'X'
        i_inplace       = 'X' ).
    endmethod.
    The function 'Y_PDF_GET' is implemented as follows:
    FUNCTION Y_PDF_GET .
    *"*"Local interface:
    *"  EXPORTING
    *"     VALUE(EX_PDF) TYPE  XSTRING
    *"  TABLES
    *"      ET_OTF STRUCTURE  ITCOO OPTIONAL
      data: lf_filesize type i,
            lt_otf type table of ITCOO,
            lt_lines type table of tline,
            tline type tline.
    * start sapscript or smatforms and return
      perform make_otf.
      CALL FUNCTION 'READ_OTF_FROM_MEMORY'
        TABLES
          OTF                = lt_otf
       EXCEPTIONS
         MEMORY_EMPTY       = 1
         OTHERS             = 2
      et_otf[] = lt_otf.
      CALL FUNCTION 'CONVERT_OTF'
       EXPORTING
         FORMAT                      = 'PDF'
    *   MAX_LINEWIDTH               = 132
    *   ARCHIVE_INDEX               = ' '
       IMPORTING
         BIN_FILESIZE                = lf_filesize
        TABLES
          OTF                         = lt_otf
          LINES                       = lt_lines
       EXCEPTIONS
         ERR_MAX_LINEWIDTH           = 1
         ERR_FORMAT                  = 2
         ERR_CONV_NOT_POSSIBLE       = 3
         OTHERS                      = 4
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * convert tline to xstring as needed in
    * in web dynpro            
      field-symbols <X>.
      data: st(268) type c.
      data l1 type i.
      data len type i.
      data maxline type i value 134.
      l1 = 0.
      loop AT lt_lines INTO tline.
        clear st.
        st+l1(maxline) = tline.
        len = maxline + l1.
        l1 = maxline - strlen( tline ).
        ASSIGN st TO <x> TYPE 'X'.
        CONCATENATE ex_pdf <x>(len) INTO ex_pdf.
      endloop.
    ENDFUNCTION.
    The make_otf for sapscript is the following:
    * the next attribute enables the otf output.
    * no other output will be generated
    <b>options-TDGETOTF = 'X'</b>
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
    *         APPLICATION        = 'TX'
    *         ARCHIVE_INDEX      = ARCHIVE_INDEX
             ARCHIVE_PARAMS     = ARCHIVE_PARAMS
                DEVICE             = DEVICE
                DIALOG             = ' '
                FORM               = FORM
                LANGUAGE           = language
               OPTIONS            = OPTIONS
    *     IMPORTING
    *          LANGUAGE           =
    *          NEW_ARCHIVE_PARAMS =
    *          RESULT             =
           EXCEPTIONS
                CANCELED           = 1
                DEVICE             = 2
                FORM               = 3
                OPTIONS            = 4
                UNCLOSED           = 5
                OTHERS             = 6.
    *... make some write forms
      data lT_OTF     type table of     ITCOO.
    * get the otf data
      CALL FUNCTION 'CLOSE_FORM'
    *     IMPORTING
    *          RESULT   = result
           TABLES
               OTFDATA  = lt_otf
           EXCEPTIONS
                UNOPENED = 1
                OTHERS   = 2.
    * put otf into memory for later usage
      if not lt_otf is initial.
        CALL FUNCTION 'SAVE_OTF_TO_MEMORY'
    * EXPORTING
    *   MEMORY_KEY       = 'DEF_OTF_MEMORY_KEY'
          TABLES
            OTF              = lt_otf.
      endif.
    For Smartforms technology it is possible to implement the same concept.

Maybe you are looking for