Issue to View PDF file in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 11:25 AM
Hello experts,
I have a feature to embed a pdf file in the service portal page, but it doesn't work for all pdf files.
I use this script
HTML
<object data="{{data.base64}}"
type="application/pdf" width="100%" height="1000px" class="internal" id="pdfPreview">
<param name="view" value="fitH" />
</object>
server side
var gr = new GlideRecord('sys_attachment');
gr.addQuery('sys_id', attach_ID);
gr.query();
if (gr.next()) {
var sa = new GlideSysAttachment();
var binData = sa.getBytes(gr);
var base64 = GlideStringUtil.base64Encode(binData);
data.base64 = 'data:application/pdf;base64,' + base64 + '#toolbar=0';
}
Is there a problem in my code? Are there any suggestions to work around this problem?
thank you in advance for your help
Cordially
Sanaa
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 07:10 PM
Hi Sanaa,
If it's working for some file, it may be a problem with the file size. Check the following question. Increasing system property "com.glide.attachment.max_get_size" is not recommended because it may decrease performance of an instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 03:47 AM
Hello Marc,
thank you for your reply,
I tried your suggestion but it still not working.
did you have any suggestion to resolve this issue.
Thank you.
Sanaa

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 05:05 AM
have you tried to open these pdf in a web page outside of ServiceNow? Do they all work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 06:50 AM
yes, I have, they work fine