Skip to Content

sap.m.PDFViewer Issue SAPUI5

Hi Experts

I'm trying to show a PDF File in a pop-up in SAP Web IDE (SAPUI5).

The OData service that returns the PDF File works fine.

1. When I make the call from my application, the PDF is not loaded correctly (stays in wait status), only downloads the file.

2. when I use the function read of the OData model, the response is the following:

What is the correct way to show the PDF file using the control sap.m.PDFViewer ?

If there is another way to show PDF files please indicate me.


I appreciate your help, thanks.

Regards.

pdf1.png (66.7 kB)
pdf2.png (7.6 kB)
pdf3.png (31.8 kB)
pdf4.png (13.0 kB)
pdf5.png (5.7 kB)
pdf6.png (13.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Feb 13 at 11:54 PM

    Hi,

    I got the same issue and, in my case, it was because I didn't specify any HTTP Header parameters in my backend method GET_STREAM.
    So the default behaviour was to download directly the file rather than display it in sap.m.PDFViewer.

    It was solved by adding this ABAP code in method GET_STREAM:
    DATA http_header TYPE ihttpnvp.
    http_header-name = 'Content-Disposition'.
    http_header-value = 'inline; filename="MyPDF.pdf";'.
    set_header( is_header = http_header ).

    Max

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 10, 2018 at 03:21 PM

    Hi Augusto,

    the examples you are refering to concern loading files from the file system. That was not the question. How can we load stream content into the PdfViewer contro from sapui5?

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 21, 2018 at 11:37 PM

    Hi Juan

    You can find 3 examples of PDF Viewer on this link: https://sapui5.hana.ondemand.com/#/entity/sap.m.PDFViewer

    For all the examples, you can see and download the code. Just click on the example and then there will be a button on the top right "show source code for this example".

    Regards,

    Auguso

    Add comment
    10|10000 characters needed characters exceeded