Create PDF's with ColdBox

Thanks to Aaron Greenlee, we have added our last feature and last ticket to ColdBox 3.5. You can now use renderdata to generate PDF’s or distribute PDF’s from binary source. We have documented the features here:

// from binary
function pdf(event,rc,prc){
  var binary = fileReadAsBinary( file.path );

// from content
function pdf(event,rc,prc){
  event.renderData(data=renderView("views/page"), type="PDF");

as you can see, you can very easily convert any view or view/layout combination into a PDF. Not only that, but render data supports event caching, so you could easily be generating PDF’s that are cached as well!

is there a way to save the PDF Rendered on the server rather than just streaming it back to the client?


result = event.renderData(data=somedata, type=“pdf”);
fileWrite(“foo.pdf”, result.getRenderData().data);


that’s what i was originally looking for, but i found an alternate way by passing in the path via pdfArgs (this writes local) and streams back

event.renderData(data=somedata, type="pdf", pdfArgs {filename=‘Fullpath/blah.pdf’} );

Awesome… It’s good to know.
Thanks for sharing!