title: How to show the custom PDF template while clicking the button
body: <p>I want to show the PDF Template in new window while clicking the button in Sales Order. I created the button in sales order process using user event script. after that i'm unable to proceed it. It is possible to show the custom PDF template in new window while clicking the sales order?</p>
  
  <p><strong>My CODE:</strong></p>
  
  <pre><code>USER EVENT SCRIPT:
  
       // creating button in user event script before load event in view mode
          unction userEventBeforeLoad(type, form, request){  
  
  
      if(type == 'view'){
           var internalId = nlapiGetRecordId();
  
              if (internalId != null) {
                  var createPdfUrl = nlapiResolveURL('SUITELET', 'customscript_back0rdered_itm_pdf', 'customdeploy_backord_itm_pdf_dep', false);
                  createPdfUrl += '&amp;id=' + internalId;
  
                  //---add a button and call suitelet on click that button and it will open a new window
                  var addButton = form.addButton('custpage_printpdf', 'Print PDF', "window.open('" + createPdfUrl + "');");
              }
              else {
                  nlapiLogExecution('DEBUG', 'Error', 'Internaal id of the record is null');
              }
      }
  }
  
  
  SUITELET SCRIPT:
  
  function suitelet(request, response){
       var xml = "&lt;?xml version=\"1.0\"?&gt;\n&lt;!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\"&gt;\n";
       xml += "&lt;pdf&gt;";
       xml += "&lt;head&gt;&lt;macrolist&gt;&lt;macro id=\"myfooter\"&gt;&lt;p align=\"center\"&gt;&lt;pagenumber /&gt;&lt;/p&gt;&lt;/macro&gt;&lt;/macrolist&gt;&lt;/head&gt;";
       xml += "&lt;body size= \"A4\" footer=\"myfooter\" footer-height=\"0.5in\"&gt;";
       var record = request.getParameter('internalId');
       xml +="record";       //Add values(in string format) what you want to show in pdf
       xml += "&lt;/body&gt;&lt;/pdf&gt;";
       var file = nlapiXMLToPDF(xml);
       response.setContentType('PDF', 'Print.pdf ', 'inline');
       response.write(file.getValue()); 
  }
  </code></pre>
  
  <p>thanks in advance</p>