View PDF file in service portal

Juliana
Kilo Expert

I need to embed a PDF file for the user to view inside the page in service portal. I have tried the following, and nothing works.

 

The iframe downloads the atttachment instead of showing it.

<iframe id="inline_document" scrolling="no" style="width:100%;height:900px;border:none" src="sys_attachment.do?view=true&amp;sys_id=bc039edadbe923008fa34410ba9619b3">
</iframe>

The embed gives error saying it can't load the document.
<embed height="200px" src="/sys_attachment.do?sysparm_referring_url=tear_off&amp;view=true&amp;sys_id=bc039edadbe923008fa34410ba9619b3" type="application/pdf" width="200px"/>

The object gives error saying it can't load the document.
<object data="https://elodev.service-now.com/sys_attachment.do?sysparm_referring_url=tear_off&view=true&sys_id=bc039edadbe923008fa34410ba9619b3" type="application/pdf" width="100%" height="50%">
<p>Alternative text - include a link <a href="myfile.pdf">to the PDF!</a></p>


</object>

1 ACCEPTED SOLUTION

Juliana
Kilo Expert

I was able to make it work by converting the content Base64!

 

find_real_file.png

 

find_real_file.png

 

View solution in original post

33 REPLIES 33

Fabian Kunzke
Kilo Sage
Kilo Sage

Hello Juliana,

As of my knowledge, the sys_attachment.do does not actually display the attachment, but rather the record itself. In this case it will download it (hence why the download is triggered). However this may help you with your solution:

https://community.servicenow.com/community?id=community_question&sys_id=c02383e1dbd8dbc01dcaf3231f96...

Greetings

Fabian

scott barnard1
Kilo Sage

Hi Juliana 

There was some talk of the document viewer plugin being enabled to allow attachments to display rather than to download however this seems to have hit some issues

I'm definitely interested in what you come up with as we have a similar use case

 

regards

Juliana
Kilo Expert

I was able to make it work by converting the content Base64!

 

find_real_file.png

 

find_real_file.png

 

Nice result, thanks for sharing