How to display PDF in a new browser?

Hi guys,
I have generated PDF using adobe life cycle manager (transaction SFP) in WDA. Now the requirement is to show the PDF in a new browser. Both views are in the same WD object. I have tried different methods to get the PDF data into the new window which i am opening using method:
lo_window_manager->create_external_window
I have the common context through component controller but the data does not reach the second view. I am guessing it is not possible to share same context if you open a new browser.
Next i tried saving the pdf in a controller class but even then i dont get the data back. The data does get stored through the set functionality.
I also tried using cl_bsp_server_side_cookie=>set_server_cookie and get_server_cookie methods and still i did not get any data.
I also tried adding the pdf data into the url and created an inbound plug in the second the view where i needed the pdf data. That url was then sent in the method create_external_window. That did not work out because pdf data is too long to be added as url parameter.
Any other suggestion. Any suggestion or code will be appreciated.
Thanks

> I am guessing it is not possible to share same context if you open a new browser.
That is correct.  New browser/external window, means new backend session.
Is this PDF interactive - or just print/view?  If it is just print/view why not consider sending it out as an attachment and then it will open in a separate Adobe Reader window.
cl_bsp_server_side_cookie=>set_server_cookie and get_server_cookie should work if you fill the parameters correctly.  All these methods do is to write the data in to a temporary database table.  Are you filling in the session id parameter?  If so where are getting the value for this?

Similar Messages

  • Display PDF on opening new browser

    Hi Experts,
    Requriement: We need to open a new browser for dispalying PDF format converted from custome smartform. Currently I am able to view the PDF format on a new screen with the following code, but user want to see the same PDF format on new browser so that they can toggle between the screens for comparing data.
    Your answers would be really helpful. Please guide me how to achieve this through ABAP, we are using 4.7 version.
    Current code looks like this
    *--- convert OTF data
      IF sy-subrc EQ 0.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
          IMPORTING
            bin_filesize          = lv_pdf_size
          TABLES
            otf                   = wa_job_info-otfdata
            lines                 = lt_pdf
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            OTHERS                = 4.
    *--- convert RAW type to Unicode format - hexadecimal format
        LOOP AT lt_pdf INTO wa_pdf.
          ASSIGN wa_pdf TO <fs_line> CASTING.
          APPEND <fs_line> TO lt_pdf_uc_data.
        ENDLOOP.
    *--- load data to prepare URL
        CALL METHOD gv_html_viewer->load_data
          EXPORTING
            url          = gc_x
            type         = 'application'
            subtype      = 'pdf'
            size         = lv_pdf_size
          IMPORTING
            assigned_url = lv_url
          CHANGING
            data_table   = lt_pdf_uc_data
          EXCEPTIONS
            OTHERS       = 1.
    *--- display smart form
        CALL METHOD gv_html_viewer->show_url
          EXPORTING
            url = lv_url.
    Regards,
    Suman

    What you can do is create a new program just to display the PDF and attached a transaction code to it. In your main program, call the FM ABAP4_CALL_TRANSACTION ... STARTING NEW TASK to call it in the new session.
    You may use the FM DY_IS_EXTRA_IMODE_AVAILABLE before starting a new session to check if any session available.
    CALL FUNCTION 'ABAP4_CALL_TRANSACTION'
      STARTING NEW TASK 'ZZ01'    " << Task Name
      EXPORTING
        tcode                         = 'ZZ01'.  "  << New Tcode
    Regards,
    Naimesh Patel

  • How to display PDF in JSP using Iframe

    Hi All,
    I am using Struts 2. I am building my file in ActionClass with seperate Method like getGeneratedPDF() in which, I am setting header of response and writing into PDF.
    This method will be called from JSP by this way
    s:property value="getGeneratedPDF()" />
    But It displayed Junk Characters , and this PDF is not static (already Generated). It is generated and build on Fly.
    I have 2 questions 1 -- How to display PDF in JSP in proper way without Junk Character in it?
    questions 2 -- How to display it in Iframe?
    Please help me , If you know the solution.
    Thanks in Advance,
    Jimmy

    jamy_26 wrote:
    But It displayed Junk Characters , and this PDF is not static (already Generated). It is generated and build on Fly.A PDF file is a binary file, not a text file, and you're trying to display it as String. Of course you would get "junk characters". Have you ever tried opening a binary file (pdf, doc, jpg, xls, etc) using a text editor like Notepad?
    I have 2 questions 1 -- How to display PDF in JSP in proper way without Junk Character in it?Display it as binary stream, not as text stream. You can display it standalone, just let the link/form/addressbar URL point to some Servlet which writes the InputStream of the PDF file to the OutputStream of the response, along with a correct set of response headers (at least content-type, content-disposition and content-length), so that the browser can open it in the correct application (which is usually Acrobat Reader). If you want to embed the PDF file in a JSP, then one of the ways is indeed using the HTML <iframe> tag.
    questions 2 -- How to display it in Iframe? Just let the iframe URL point to the aforementioned Servlet.
    You can find here an example of a generic file servlet, you may find it useful to get the idea how to do it: [http://balusc.blogspot.com/2007/07/fileservlet.html].

  • How to display Pdf file in iPad site

    Hi
    How to display Pdf file in web page which can able to view in iPad safari?
    Thanks,
    Arun

    You can't really.
    You need to use DHTML in the swf-wrapper HTML file, usually a
    division wrapped iFrame, and load the PDF into the iFrame as an
    overlay to the Flash.

  • Display pdf in a new window

    I need to display the pdf in a new window on click of a button in the iview. The pdf is fetched as an array of bytes from an RFC. It displays correctly, but in the same window. Pls see the extract of the code:
    To Write
    writeText(IPortalComponentRequest request, IPortalComponentResponse response, byte[] pdfResult)
    try{
    Document doc = new Document(PageSize.A4);
    javax.servlet.http.HttpServletResponse myResponse = request.getServletResponse(true);
    myResponse.setHeader ("ContentDisposition", "inline;filename=\"ShortCV.pdf\"");
    myResponse.setContentType("application/pdf");
    OutputStream os = myResponse.getOutputStream();
    os.write(pdfResult);
    PdfWriter.getInstance(doc,os);
    catch(Exception Ex){
    OnView(Event evt){
    JCO.Field Table1 = m_function.getExportParameterList().getField("PDF_STRING");
    client.execute(m_function);
    writeText(request, response, Table1.getByteArray());
    onView is called on
    Button myButton11 = new Button("myButton11");
    myButton11.setText("View");
    myButton11.setOnClick("View");
    myButton11.render(rendererContext);
    Pls advice

    See Display pdf in a new Window in a JSPDynPage

  • Opening Hyperlinks from PDF in a new browser Window

    We have a web based (ASP.NET) tool to author HTML content. Authors can create/edit HTML content, preview, and save the file as PDF. A 3rd party component- abcpdf is used to convert HTML into PDF. The converted PDF form will be distributed to consumers.
    The PDF typically contains Hyperlinks, text boxes and submit button.
    Clicking the hyper link in PDF should open the HTML in a new browser instance. It should not hijack (overwrite or reuse) existing browser instance that may be active in users computer irrespective of browser setting. Changing the browser setting IE: Internet Option > Advanced > Reuse windows for launching shortcuts is not acceptable by users.
    Please let us know the solution if any

    Hi Sarah ,
    You can right click on the link and choose properties and then in the actions tab you can select the desired action you want .
    You will get a list of various actions specifying how and where do you want to open that link.
    Try this and let us know how it goes.
    Regards
    Sukrit Dhingra

  • Display PDF document in web browser

    Hi,
    I have a smartform which is being triggered from Web UI. I got the data and converted it to PDF format.
    I need to display this PDF data in a web browser Pop up.
    Please let me know how can I do that.
    Thanks
    Abhishek

    Abhishek,
    If you are using the business transaction types, you can setup a default "print" action which then when you click on the "print preview" in the webUI you will get an PDF output view of the print output.
    If that doesn't work, then look at the business partner factsheet code delivered by SAP which will show how to display a PDF.
    Look at component/view BP_HEAD/BPHEADOverview
    Class CL_BP_HEAD_BPHEADOVERVIEW_IMPL
    method IF_BSP_WD_TOOLBARR_CALLBACK~GET_BUTTONS
    and this section of code
          IF lr_partner IS BOUND AND lv_enabled = abap_true.
            lr_partner->get_property_as_value( EXPORTING iv_attr_name = 'BP_GUID'"#EC NOTEXT
                                               IMPORTING ev_result    = lv_partner_guid ).
            IF lv_partner_guid IS NOT INITIAL.
    *       ICF handler class prepares java script
              CALL METHOD cl_crm_afs_print=>get_url
                EXPORTING
                  iv_object   = lv_object
                  iv_key      = lv_partner_guid
                  iv_role     = lv_business_role
                  iv_language = sy-langu
                  iv_form     = ' '     "read from customizing
                  iv_format   = lv_format
                IMPORTING
                  ev_url      = lv_url.
              IF lv_url IS INITIAL.
                lv_enabled = abap_false.
              ELSE.
                lr_cuco_head ?= get_custom_controller( 'BP_HEAD/Lifecycle' )."#EC NOTEXT
                IF lr_cuco_head IS BOUND.
    *              CONCATENATE '"' lv_url '"' INTO lr_cuco_head->gv_preview_url.
                  lr_cuco_head->gv_preview_url = lv_url.
                ENDIF.
              ENDIF.
            ENDIF.
            ls_button-text  = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BP/BP_PDF' )."#EC NOTEXT
            ls_button-tooltip  = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BP/BP_FS_PREVIEW' )."#EC NOTEXT
    *        ls_button-on_click = 'PREVIEW'.
            ls_button-on_client_click = 'OpenPopUp()'.          "#EC NOTEXT
            ls_button-page_id  = me->component_id.
            ls_button-enabled = lv_enabled.
            ls_button-icon_src = '/sap/bc/bsp/sap/crm_ppm/w_pdf__s.gif' ."#EC NOTEXT
            APPEND ls_button TO rt_buttons.
            CLEAR ls_button.
          ENDIF.
        ENDIF.
      ENDIF.
    Good luck,
    Stephen

  • How to display PDF on a page

    Hi,
    I have a pdf document out on intranet site that I would like to have a APex report link to that document.
    This is how I defined the page:
    Page type - URL
    region source - http://www.xxx.xxx/../xxx.pdf
    It took a long time to bring up the pdf and the document is displayed in the wrong format. Has anyone done it before? How can I display pdf in APEX?
    Thanks,
    Julie

    Hello Julie,
    Here is how I handle making my user's reference manual available from my application. It is a PDF stored like yours.
    1. Define item as: Display as Text (excape special characters, does not save state)
    2. Make your Label something like this: &lt;a href="[http://www.mydomain.com/.../.../.../document.pdf] target="_blank"&gt;System User Manual&lt;/a&gt; (substitute your link info of course)
    target="_blank" opens the document in a new window.
    3. Set Horizontal/Vertical Alignment appropriately (I use Left).
    4. Template: Optional Label
    The remaining items do not matter.
    The things now that will dictate how long to download the PDF are, network speed on your end, network speed on the recipient end, network load, size of the PDF and the other normal things that cause a download to be slow.
    Hope this helps,
    Don

  • PDF viewer into new browser window

    Hello,
    I use following code to open new browser window with PDF file. The URL passed to the method is link to SICF service which returns the PDF in the request with content-type = 'application/pdf'. New window is open with correct URL, but the content is not displayed - Refresh or Go button has to be pressed to display it. Don't you experience similar problem? Is this WD error or some IE security setting?
    Thank you and best regards,
    Ludek
      lr_window = lr_w_manager->create_external_window(
          url = ld_url
          title = ''
          modal = abap_false
          has_menubar = abap_true
          is_resizable = abap_true
          has_scrollbars = abap_true
          has_statusbar = abap_true
          has_toolbar = abap_true ).
      lr_window->open( ).

    Hi Ludek,
    Probably a compression problem. Have you turned off gzip compression for the pdf?
    Btw, an alternate solution without having a separate handler is to use the cl_wd_runtime_services=>attach_file_to_response() method.
    Best regards,
    Thomas

  • How to display the velocity template in browser

    Hi All,
    Am new to vm. Can anyone help me, how to display the content of .vm file in browser ?
    Am able to display the content of .vm file in console.
    Whether this is because of any path issues ?
    Thanks in Advance.

    Hi PKG,
    I think the easiest way to achive this, is to design your RenderListItem form like your ShowForm and restrict the number of items in your collection renderer to "1".
    So a list is rendererd with exactly one item.
    Kind Regards
    --Matthias

  • How to display "Image" object in the browser?

    can anyone please tell me how can i display "Image" object in the browser?
    I have an image object that i retrieved from AS400 BLOB object by using toolbox.jar (for as400 access for java including all necessary classes like jdbc driver, security etc.).
    i want to display this object in the browser so i will be able to web-enable my BLOB objects stored on as400.thx...

    In your HTML:
    <img src="ImageServlet">
    In ImageServlet:
    Make calls to DB to get your image as byte array and store it in:
    byte[] buffer = new byte[imageSize];
    ServletOutputStream out = response.getOutputStream();
    for(int i = 0; i < imageSize; i++)
    out.write(buffer, i, 1);
    out.close();

  • How to display pdf file in windows phone 8 silver light application?

    Hi,
    I am developing windows phone 8 silver light application . For my app I want to display pdf files . Is there any default controls to display pdf files ?
    I don't want to display using launchers , I want to display with in the app.
    any help,
    Thanks..
    Suresh.M

    Probably this should give you a fair idea : How to view PDF file inside an Windows Phone application?
    http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

  • How to display pdf file with java code?

    Hi All,
    i have a jsp pagein that page if i click one icon then my backing bean method will call and that method will create pdf document and write some the content in that file and now i want to display that generated pdf document.
    it should look like you have pressed one icon and it displayed pdf file to you to view.
    java code below:
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "filename=\"" + temppdfFile);
    resp.encodeRedirectURL(temppdfFile.getAbsolutePath());
    resp.setContentType("application/pdf");
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(temppdfFile, out);
    out.flush();
    and above temppdfFile is my generated pdf file.
    when i am executing this code, it was opening dialog box for save and cancel for the file, but the name of the file it was showing me the "jsp file name" with no file extention (in wich jsp file i am calling my backing bean method) and type is "Unknown File type" and from is "local host"
    it was not showing me open option so i am saving that file then that file saved as a pdffile with tha name of my jsp file and there is nothing in that file(i.e. empty file).
    what is the solution for this. there is any wrong in my code.
    Please suggest me.
    Thanks in advance
    Indira

    public Object buildBarCodes() throws Exception
    File bulkBarcodes = null;
    String tempPDFFile = this.makeTempDir();
    File tempDir = new File("BulkPDF_Files_Print");
    if(!tempDir.exists())
    tempDir.mkdir();
    bulkBarcodes = File.createTempFile
    (tempPDFFile, ".pdf", tempDir);
    //bulkBarcodes = new File(tempDir, tempPDFFile+"BulkBarcode"+"."+"pdf");
    if(!bulkBarcodes.exists())
    bulkBarcodes.createNewFile();
    Document document = new Document();
    FileOutputStream combinedOutput = new FileOutputStream(bulkBarcodes);
    PdfWriter.getInstance(document, combinedOutput);
    document.open();
    document.add(new Paragraph("\n"));
    document.add(new Paragraph("\n"));
    Image image = Image.getInstance(bc.generateBarcodeBytes(bc.getBarcode()));
    document.add(image);
    combinedOutput.flush();
    document.close();
    combinedOutput.close();
    FacesContext facesc = FacesContext.getCurrentInstance();
    ExternalContext ec = facesc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "inline: BulkBarcodes.pdf");
    resp.encodeRedirectURL(bulkBarcodes.getAbsolutePath());
    resp.setContentType("application/pdf");
    resp.setBufferSize(10000000);
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(bulkBarcodes, out);
    out.flush();
    return "success";
    This is my action method which will call when ever i press a button in my jsp page.
    This method will create the barcode for the given barcode number and write that barcode image in pdf file
    (i saw that pdf file which i have created through my above method, This PDF file opening when i was opening manually and the data init that is also correct means successfully it writes the mage of that barcode)
    This method taking the jsp file to open because as earlier i said it was trying to open unknown file type document and i saved that file and opended with editplus and that was the jsp file in which file i am calling my action method I mean to say it was not taking the pdf file which i have created above it was taking the jsp file

  • How to Open Hyperlink in a New Browser?

    Hi, 
    I have a hyperlink in my report that takes the user to a webpage and from my ASP application, I want the hyperlink to open a new browser session or tab instead of taking over my current session and losing my report.  This will give the users the ability to flip back to the report and open another page if they need to. 
    Interesting how right-clicking the hyperlink has Open in New Tab and Open in New Window greyed out. 
    Windows application works fine and the hyperlinks open in their own tab. 
    Is there a way to encapulate the url from the hyperlink in a javascript popUp? 
    I'm using CRVS2010 in VS2010. 
    Thanks,
    Brian

    Hi Brian,
    On the properties page of the view find the Property HyperlinkTarget, default is set to _self, change it to _blank.
    Have fun
    Don
    PS - Thanks to Dan P. For this.

  • Problem displaying PDF file in new window.

    Using NetBeans 6.5, Internet Explorer 7.
    I am using the code example from BalusC at the site:
    http://balusc.blogspot.com/2006/05/pdf-handling.html
    I am having no problem reading and displaying the PDF file, but it displays it in the same window,
    not a new window and it overwrites the current page, so I can't use the back arrow to fetch the page that is overwritten.
    I am using a commandLink to fetch the file.
    Does anyone know why I am not getting a new window or tab for the display?
    The jsp portion for the link is:
    <h:commandLink action="#{MainPage.linkAction3_action}" id="linkAction3"
              style="color: rgb(0, 0, 0); font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; left: 280px; top: 0px; position: absolute"
              target="_blank" value="Insurance Document"/>The "MainPage.linkAction_action" method just makes a call to the display function:
        public String linkAction3_action() {
            sb1.setMessage("");
            dsb.setFilePath("C:/");
            dsb.setFileName("Insurance_Summary.pdf");
            dsb.downloadPDF();
            return null;
        }And the downloadPDF() method is basically a cut and paste from the BalusC site;
        public void downloadPDF()
            // Reference:   http://balusc.blogspot.com/2006/05/pdf-handling.html
            // Prepare.
            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
            File file = new File(getFilePath(), getFileName());
            BufferedInputStream input = null;
            BufferedOutputStream output = null;
            try {
                // Open file.
                input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
                // Init servlet response.
                response.reset();
                response.setContentType("application/pdf");
                response.setContentLength( (int)file.length());
                response.setHeader("Content-disposition", "inline; filename=\"" + fileName + "\"");
                output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
                // Write file contents to response.
                byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
                int length;
                while ((length = input.read(buffer)) > 0) {
                    output.write(buffer, 0, length);
                // Finalize task.
                output.flush();
            catch( Exception e )
                System.out.println( "Error displaying file.");
            finally {
                // Gently close streams.
                close(output);
                close(input);
            // Inform JSF that it doesn't need to handle response.
            // This is very important, otherwise you will get the following exception in the logs:
            // java.lang.IllegalStateException: Cannot forward after response has been committed.
            facesContext.responseComplete();
        }

    1) window.open will open a new window and call a servlet.
    window.open ("http://path_to_yourservlet/PDFServlet", "newWindowName");
    if you ant to pass some values from your web page to the servlet you can pass as
    window.open ("http://path_to_yourservlet/PDFServlet?param1=value1&param2=value2", "newWindowName");
    2) The servlet will fetch and display the pdf file.
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class PDFServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet
         private final static int DEFAULT_BUFFER_SIZE = 1000;
         public PDFServlet()
              super();
         public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              String fileName = "Insurance_Summary.pdf";
              File file = new File("C:/"+fileName+"");
              response.setContentType("application/pdf");
         OutputStream output = response.getOutputStream();
         BufferedInputStream input = null;
         //BufferedOutputStream output = null;
         try {
         // Open file.
         input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
         response.setContentLength( (int)file.length());
         response.setHeader("Content-disposition", "inline; filename=\"" + fileName + "\"");
         output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
         // Write file contents to response.
         byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
         int length;
         while ((length = input.read(buffer)) > 0) {
         output.write(buffer, 0, length);
         output.flush();
         catch( Exception e )
         System.out.println( "Error displaying file.");
         finally {
         input.close();
    Regards,
    Milind Dhar

Maybe you are looking for

  • Why does my laptop computer automatically write "ccc" and "bbb"?

    I have Toshiba Sattelite L300 laptop which automatically writes these letters "cccc" and "bbbb" (ONLY these two letters). I bought this laptop 11 months ago and it is still under 1-year basic guarantee that will expire within few weeks. Few months ag

  • Error in JMS Adapter Configuration.

    Hi, Its regarding JMS receiver adapter for MQ Series. We  have MQ 6.0 installed on PI server. While trying to connect thorough JMS receiver adapter we are getting a connection failure error at communication channel level. The MQ administrator is of t

  • "Could not create Java virtual machine" for several XP SP3 clients

    Hi, In this last year I got the message "could not create java virtual machine", (suddenly, after several mounths without any kind of problem), on 10-15 XP SP3 clients in our lan, lan in which all the 200 clients (90% XP SP3) have this application in

  • I cant download ibooks for mac for free

    Im trying to download ibooks for mac but i cant, it says i should have OS X 10.7.2, what i have now is 10.6.8. do i have to purchase the latest version and pay $20.99? why i cant download it for free?

  • Query heirarchies

    Is it possible to do the following and if so how? We have 2 heirachies old and new.  In the new heirarchy some values have moved to a different node Before the beginning of the year we want to show the values on the old heirarchy and after as on the