In-line .PDF display in Knowledge

Ben Blackburn
Tera Contributor

Still waiting on some way to natively display .PDF files within a knowledge article.  I know there used to be an app on Share that would handle this, but I'm not finding it anymore (and I think it got deprecated).  Currently, I'm having my user base convert the .PDFs to .DOCX, then import those documents using the OOB functionality, but the formatting is never perfect.  I suspect the same challenges will exist if I have them convert to HTML.

Does anyone have a good solution for this?

1 ACCEPTED SOLUTION

Rajesh Kannan G
ServiceNow Employee
ServiceNow Employee

You can use ServiceNow Document Viewer plugin to display PDF in articles. 

 

1. Whitelist iframe tag and src, height, width attributes by updating HTMLSanitizerConfig.

find_real_file.png

2. Enable ServiceNow Document Viewer plugin. I think this requires additional license.

3. Attach PDF file to your article. Use source code button to open HTML Source code of the article and add iframe tag to display PDF in your article. The sysparm_sys_id parameter is the sys_id of your attachment.

find_real_file.png

find_real_file.png

4. Publish your article.

Article will be displayed as shown below.

find_real_file.png

View solution in original post

31 REPLIES 31

Hi,

 

this option does work! Do you have a way of making it work for the service now mobile app. When i open up a knowledge article on the mobile app, it looks like the below image. How can we fit the inline pdf to fit the mobile app screen?

find_real_file.png

I followed your instructions. The PDF displayed well but is there a way to make the height = 100% instead of having it as 700px?

When I used your script, even if I changed the height to 100%, the view of the PDF doesn't display as 100%. Thanks.

 

@Rajesh Kannan G , where to find html sanitizer configuration ?

Is the text searchable with this solution?

john_duchock
Kilo Guru

While this does work quite well, my users are being prompted for a Username and Password when the PDF opens.  I have advertised this as a "security feature", but it wont be long before someone asks if an article (or category or knowledge base) can be more public.  I am not sure what is imposing this login requirement for each KB article displayed as the user is already logged in...

Additionally, when in Chrome and Opera, the popup window for login is removed fairly quickly because of the "This document could not be previewed." message that inevitably is displayed.  Believe it or not, IE/Edge do not suffer from this...

Any idea how to either disable the login requirement or at least provide it with a timer to allow users enough time to log in?

 

EDIT:  I created a hi ticket as it appears that the API call does not have auto-auth and a 5000ms timeout for authentication.  This does not give a user enough time to log in to view the embedded PDF attachment within the iframe.