on 11-07-2012 11:47 AM
Hello Experts,
I'm using ADS in my WDJ project.
When I create new adobe form the xdp is created under src -> configuration -> Components -> <Component Name> -> xdp files.
In order to create PDF on the fly I need to use the 'setTemplate' method of the interface 'IWDPDFDocumentCreationContext'.
Although the method has several signatures:
void setTemplate(byte[] template)
void setTemplate(OutputStream templateStream)
void setTemplate(String URL)
I still need to access the xdp source file.
I couldn't find API to access xdp file under 'src -> configuration -> Components -> <Component Name>'.
A possible workaround is to copy the xdp to the component's mimes folders and access it by
templateUrl = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getDeployableObjectPart(), "CopyOf.xdp");
I want to avoid this solution.
So, how can I access the xdp files without copy it?
Version is 7.00 SP22.
Regards,
Omri
Omri,
I've had this issue in the past and the only workaround I found was what you posted. If you do find a solution, please update this thread. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Solved it on my own (or to be more precise by using to following code):
https://gist.github.com/403956
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());
}
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.