- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 07:55 AM
Is it possible to export custom html created in widget to pdf then download?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 08:57 AM
Hello @cnough ,
I do not understand the use case, but it's pretty simple to create a pdf if you have the data and a record to attach it to.
See the below script:
var html = '';
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var gr = new GlideRecord("kb_knowledge"); //attaching to a kb record for demo purpose
if (gr.get('c85cd2519f77230088aebde8132e70c2')) { //this is a kb record sysid, the attachment will attach here
html = gr.text.toString();
}
var result = v.convertToPDF(html, "kb_knowledge", "c85cd2519f77230088aebde8132e70c2", "myPDF");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2022 01:31 AM
The above code fetches the content from the kb_knowledge table and then exports, its similar to how export works from form. But is there a way just click a button on the portal and the contents of the widget exports to a PDF with the color styling etc? I want this to export the knowledge article from Portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2022 08:57 AM
Hello @cnough ,
I do not understand the use case, but it's pretty simple to create a pdf if you have the data and a record to attach it to.
See the below script:
var html = '';
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var gr = new GlideRecord("kb_knowledge"); //attaching to a kb record for demo purpose
if (gr.get('c85cd2519f77230088aebde8132e70c2')) { //this is a kb record sysid, the attachment will attach here
html = gr.text.toString();
}
var result = v.convertToPDF(html, "kb_knowledge", "c85cd2519f77230088aebde8132e70c2", "myPDF");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2022 01:31 AM
The above code fetches the content from the kb_knowledge table and then exports, its similar to how export works from form. But is there a way just click a button on the portal and the contents of the widget exports to a PDF with the color styling etc? I want this to export the knowledge article from Portal.
