public Object generatePDF(Document dataset) throws IOException
{
// Open shell XDP containing XFA template based on servlet context (in this case webapp root)
String source = FlexContext.getServletContext().getRealPath("/pdfgen_contact/contact.xdp");
XDPXFAHelper helper = new XDPXFAHelper();
helper.open(source);
// Import XFA dataset
helper.importDataset(dataset);
// Save new PDF as a byte array in the current session