Embedding a PDF view in a knowledge base article - iframe code is lost when article is submitted

Chuck_P
Tera Contributor

We want to be to present the content of a pdf in the knowledge base article. We put in the iframe source code to present the pdf. It works in draft mode. When we submit the article, it loses one line of iframe code: the src line with the url address that references the attachment. Basically, we are experiencing what this guy on youtube experienced and couldn't solve https://youtu.be/wGZ_ADn87wU?si=nXs4jIFf_WC0xB4Y.  Thanks for the help.

There is a hack you can use to embed PDF in Service now KB article, otherwise it will just download the PDF each time you want to view it which can be quite annoying.
2 REPLIES 2

Mark VL
Tera Expert

Chuck,

 

You can easily drag and drop a PDF into a KB article with the ServiceNow-native Amaze application available through the ServiceNow Store.  Videos, too.  Check it out:   Amaze Article Builder for ServiceNow by Intellective

Community Alums
Not applicable

Hi @Chuck_P ,

 

This might be due to the HTML Sanitizer Scripts present in the system as the <iframe> tag is not allowed due to possible vulnerability to cross domain attacks.

 

You need to modify the HTMLSanitizerConfig script include to whitelist iFrame tags.

SanjayG_0-1721339523765.png

 

This screenshot is OOTB config.

 

Update you need to do-

	HTML_WHITELIST : {
		globalAttributes: {
			attribute:[],
			attributeValuePattern:{}
		},
		iframe:{
			attribute:["width", "height","src","frameborder","allow","allowfullscreen"],
			attributeValuePattern:{}
		 },
	},

 

 

 

Know more about - https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/security/concept/c...

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!


Thanks & Regards,

Sanjay Kumar