- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2018 03:25 AM
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&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&view=true&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>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 02:48 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 01:22 AM
This works for me fine:
HTML: (from Ashley's script, but do not forget to use {{data.final_string}} instead of {data.final_string})
<object data="{{data.final_string}}"
type="application/pdf"
height="100%"
width="100%"
class="internal">
</object>
In server side for SCOPED app you can use this method:
var sa = new GlideSysAttachment();
var gr = new GlideRecord('sys_attachment');
gr.get('d02cea531b029010d6c54229bc4bcb5b'); //sys_id of your attachment
var content = sa.getContentBase64(gr);
data.final_string = "data:application/pdf;base64,"+content;
OR you can store your base64 in property, and just use it like I did (string property with full base64 code in value):
var content = gs.getProperty('x_aaro2_hris_acces.document_to_sign_base64');
data.final_string = "data:application/pdf;base64,"+content;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 01:50 AM
Hi,
how will it work if the pdf is external stored. lets say sharepoint. So it above example would it be then:
<object data="https://sharepoint.blabla.com/blabla/file.pdf"
type="application/pdf"
height="100%"
width="100%"
class="internal">
</object>
or still being using iload. Is to view the pdf directly on the HTML / portal content..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 02:16 AM
Good Morning,
A couple of articles that might help:
https://www.reddit.com/r/servicenow/comments/d8z4b7/how_to_expose_data_from_external_application_in/
https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/remote-tables/concept/remote-tables.html
Kind Regards
Ashley
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 05:33 AM
I have added these scripts on my widget and sys ttachment has a PDF. used sys if of that here but PDF is not embeding.