Skip to content

Instantly share code, notes, and snippets.

@indaco
Created May 17, 2010 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indaco/403956 to your computer and use it in GitHub Desktop.
Save indaco/403956 to your computer and use it in GitHub Desktop.
...
try {
IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
IWDPDFDocumentCreationContext pdfNewDocContext = pdfDocumentHandler.getDocumentCreationContext();
String templateUrl = WDURLGenerator.getPublicResourcePath(wdComponentAPI.getDeployableObjectPart(), "IF.xdp");
InputStream template = new FileInputStream(templateUrl);
byte[] byteFileArray = new byte[template.available()];
template.read(byteFileArray);
pdfNewDocContext.setTemplate(byteFileArray);
pdfNewDocContext.setData(WDInteractiveFormHelper.getContextDataAsStream(wdContext.nodeDataSource()));
IWDPDFDocument document = pdfNewDocContext.execute();
IWDResource resource =
WDResourceFactory.createCachedResource(document.getPDF(), "test.pdf", WDWebResourceType.PDF);
wdContext.currentContextElement().setPdfResource(resource);
} catch (Exception e) {
this.msgMgr.reportException(e.getMessage());
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment