Behavior: FormatPdf

Applies filters that will automatically convert views into PDF documents

This behavior uses a “afterRender” filter that listens for Action calls with a “format” parameter that equals “pdf”.  When discovered, normal output is suppressed and instead the content produced is converted to a PDF file and served to the browser.

If params.filename is defined the pdf will be served for download with that name.

// in app/controllers/<name>_controller.sjs
function init(){

// calling this with ?format=pdf will cause it to return an inline PDF document
// containing the view output.
// Passing filename=output.pdf will cause the PDF with that name to be downloaded
function list(params){
this.$page.title = "All Items"