Create a PDF file without attach it to any table

demgnekamdem
Tera Contributor

I write following code which create a pdf file and attach it ti incident table :

 

  var document = null;
        var pdfDoc = new GeneralPDF.Document(null, null, null, null, null, null);
        document = new GeneralPDF(pdfDoc, null, null);
        document.startHTMLParser();
        document.addHTML(this.getParameter('sysparm_html'));
		document.stopHTMLParser();
        var att = new GeneralPDF.Attachment();
        att.setTableName("incident");
        att.setTableId("e8caedcbc0a80164017df472f39eaed1");
        att.setName("filename");
        att.setType('application/pdf');
        att.setBody(document.get());
        GeneralPDF.attach(att);

 

I want to know if it possible to create a pdf file in ServiceNow without attach il to any table ? I yes, how can I improve my code ?

 

Thanks in advance,
Carole

2 REPLIES 2

Apollo7135
Kilo Contributor

Thanks for sharing it here. As I was creating pdf for nagaland state results manually but that was not getting attached. Going to try this method I hope it will work for us and we will easily provide the pdf file without attachement.

Ryan66
Tera Contributor

Any luck with this?  I'm trying to do the same thing.  Have the need to generate a document and download immediately, but without having to store the attachment in the system.  Thanks!