Wednesday, October 17, 2018

Print mode for the document Using nlapiXMLtoPDF

Using nlapiXMLtoPDF, we can set the document (PDF) to be in print mode right away upon invoking the script. 

Notice on the following code sample that the javascript within the XML "myinit()" function, invokes the print mode option on event "onload".

Code Snippet:

// Converting XML to PDF in print mode

var xml = '<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">';
xml += '<pdf onload="javascript:myinit()">';
xml += '<head><meta name="title" value="Invoice"/>';
xml += '<script> <![CDATA[ function myinit() { this.print(); } ]]> </script> ';
xml += '</head> <body> Hello World<br/> </body> </pdf>';
 
var file = nlapiXMLToPDF( xml );
response.setContentType('PDF','print-me.pdf');
response.write( file.getValue() );  

 

No comments:

Post a Comment