- 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
04-11-2021 11:27 PM
Try to look into Variable type Macro - with it you can include custom widget to be displayed in record producer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2021 02:23 AM
Thanks, can you please tell me where to increase the page content size ? I can see the PDF file now, but its very small, I need to get it fit on full page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 10:51 AM
Hi Juliana,
thanks for post. What is the best way to create the attachment in the first place? I have my PP file, and have created my record for it in the [sys_attachment] table, then I created a widget using your code. But when I put the widget on my portal page, nothing is showing at all. Any help would be great. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 05:32 AM
I have added these scripts on my widget and sys attachment has thePDF. used sys if of that here but PDF is not embeding.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:53 AM
I have the exact same client and server code as above, there is no error but PDF is not shown on the widget on portal. What is missing ?
2 Widgets are part of portal page. Page renders 1 other widget but not this widget meant for pdf embed
Server code of widget
(function() {
var attach = '99e44c6797bb7910d8a97c9fe153af44'; // sys id of record that has the pdf attachment
var gr = new GlideRecord('sys_attachment');
gr.addQuery('sys_id', attach);
gr.query();
if(gr.next()) {
var sa = new GlideSysAttachment();
var binData = sa.getBytes(gr);
var base64 = GlideStringUtil.base64Encode(binData);
data.base64 = base64;
data = base64;
}
})();
HTML code
<object data="data:application/pdf;base64,{{data.base64}}" type="application/pdf" width="50%" height="60%" class="internal">
<param name="view" value="fitH" /></object>