cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 PDFViewer Source property doesn't accept base64 pdf path?

0 Kudos

Hi,

Thanks in Advance,

I am using SAPUI5 PDFViewer in my application. When I set the source property to the pdf file path, it is working fine. But when I set the base64 pdf value to the source property, the pdf is not visible.

Kindly provide any solution, or is there any way to extend the sapui5 control to adapt to the base64 pdf value as source.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi Ajit Kumar B.

Did you find or get a solution for this?

former_member484715
Contributor
0 Kudos

Define your PDFViewer like this :

<PDFViewer source="data:application/pdf;base64,{/Source}" title="{/Title}" height="{/Height}">
				<layoutData>
					<FlexItemData growFactor="1" />
				</layoutData>
			</PDFViewer>

Whenever you use base64 encoded data, you have to mention the data parameter while rendering the data in the browser.

Hope this helps,

Regards.

irfan_gokak
Contributor
0 Kudos

Hi Ajit,

Use it as following it'll work.

<iframe src="data:application/pdf;base64, yourBase64ContentGoesHere" />
0 Kudos

i have tried but it showing garbage values.Can you please give me entire flow like XML View and Controller code.

5555.jpg

i am using view code:

<core:HTML id="idFrame"/>

controller code:

var zid = '00001 Definitions';

var sRead = "/DisplayPDFSet(FILENAME='" + zid + "')/$value";

oModel.read(sRead, {

success: function (oData, oResponse) {

var pdfURL = oResponse.body; //if you use Oresponse.responseuri; not getting any output

pdfURL = "data:application/pdf;base64," + pdfURL;

var html = that.getView().byId("idFrame");

html.setContent('<iframe src="' + pdfURL +'" width="100%" height="100%"></iframe>');

Could you please help me it is very urgent issue for me.

Thanks advance.

0 Kudos

am using gateway side like below:

DATA base64 TYPE string.

CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
EXPORTING
input = li_zhr_policy_line-content //XSTRING Format content
IMPORTING
output = base64.
ls_stream-value = base64.

ls_stream-mime_type = 'application/pdf'.

copy_data_to_ref( EXPORTING is_data = ls_stream

CHANGING cr_data = er_stream ).

please check and let me know where i did wrong and give me example for working fine code.

Thanks advance.

Regards,

Laxmi