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

Yeah, I found that as well.  Not sure why the creds aren't being passed, but please update here when you get a response to your HI ticket.  Is there a PRB associated with the issue?

I ended up closing the HI ticket as I had another project kicking off...

we did, however, upgrade to New York and in my testing, it seems that users no longer have to provide credentials to view embedded PDF's....so that is resolved in NYp3+

I do see a problem with this method though...  it requires someone to update the HTML on the article to reference the sys_attachment.  I will begin working on a record producer that will allow the user to submit a KB article with attachment and will script the creation of the HTML information...

Cheers !

Yeah, there was a recent patch that was supposed to address this issue and so far after Madrid Patch 3a my users are no longer reporting the problem.

Thanks, John!

suryaprakash123
Tera Expert

Hi @Rajesh Kannan Gurusamy 

 

Thank you for your reply, It was helpful to us, In addiction to that, how we will do the same with multiple PDF documents. How will show that. Kindly help me on the same.

 

Thank you.

Do automation to create Knowledge article and attach file to that :

 
User below script to configure Article body with viewer :
var gr=new GlideRecord("kb_knowledge");
gr.addQuery('number','KB0010004');
gr.query();
while (gr.next()){

var attachment_id;
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id',gr.sys_id);
attachment.query();
if(attachment.next()){
gs.addInfoMessage('sys_id of the attachment is : ' +attachment.sys_id);

attachment_id = attachment.sys_id;
var url = "$viewer.do?sysparm_stack=no&sysparm_sys_id=" + attachment_id ;

gr.text = "<p><iframe src= " + url + " width='100%' height='700px'></iframe></p><p><br /></p>";
gr.update();
}
}