
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2021 10:53 PM
Hi,
Kindly help me to export KB article as PDF. I need a button called Export as PDF in kb_article page which will export the repective KB article as PDF.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2021 05:47 AM
You can use the same script include provided.
Add the following lines in your html and client script on the clone Knowledge Article Content widget
<li class="kb-menu-entry" ><a href="" ng-click="c.exportThisArticle()"><i class="fa fa-print" aria-hidden="true"></i> Print</a></li>
c.exportThisArticle=function()
{
var ga = new GlideAjax('DownloadPDFCustom');
ga.addParam('sysparm_name' , 'kbArticleDownload');
ga.addParam('sysparm_kbID',c.data.article_sys_id);
ga.getXML(getResponse);
}
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
window.open(answer);
}
Script Include
var DownloadPDFCustom = Class.create();
DownloadPDFCustom.prototype = Object.extendsObject(AbstractAjaxProcessor, {
kbArticleDownload: function() {
var kbID = this.getParameter('sysparm_kbID');
var kbContent = '';
var kb = new GlideRecord("kb_knowledge");
if (kb.get(kbID)) {
kbContent = kb.text.toString();
}
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.convertToPDF(kbContent, "kb_knowledge", kbID, kb.getValue('short_description')); //updated the title of pdf
return '/sys_attachment.do?sys_id=' + result.attachment_id;
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2021 06:38 AM
For service portal Pranesh already shared.
Since you asked for native so I mentioned the UI action which would work on native form for kb record
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 02:32 AM
Hi
Thank you for your help. I could see the articles are exported without images. Could you please suggest any way that PDF are exported with the images in KB Articles.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 02:50 AM
Hi,
is this not giving image?
function printPage(){
printList('25000');
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 02:57 AM
In Service Portal Ankur, For the solution which Pranesh gave..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 03:11 AM
Hi,
Okay in portal as per Pranesh's approach images are not coming?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader