on 07-02-2010 7:22 AM
Hi All,
Is there any way to call ADS methods to create pdf and set meta data from a java class in NWDS?
Thanks & Regards,
Sanoosh
I believe Java WD is what you´re looking for. I can set meta data in ABAP coding and I believe the same think you should be able to do from Java. Otto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Otto,
Thanks for your response. I am not using Wd Java. It is a Core Java class.
My intension is to use adobe forms in ecc 4.7. For that I will be passing xstring data from ABAP to Java through RFC.
In Java side I have a listener class. It will receive the data in byte-array format.
Now I have to call ADS for pdf creation and meta data setting.
It can be done using iText API but I feel it would be better if the ADS call can be done from the Java class.
Thanks & Regards
Sanoosh
Hi,
I've got only a method to generate the PDF using an interactive form (note: this code works with the version 7.0.21).
You can then use the byte array to concatenate several form using a library like iText or do some other process.
public byte[] generatePDF( )
{
//@@begin generatePDF()
byte[] res = null;
try {
String templateName = "yourInteractiveForm.xdp";
IWDPDFDocumentHandler documentHandler = WDPDFDocumentFactory.getDocumentHandler();
IWDPDFDocumentCreationContext creationContext = documentHandler.getDocumentCreationContext();
creationContext.setDynamic(false);
creationContext.setInteractive(false);
ByteArrayOutputStream templateSourceOutputStream = new ByteArrayOutputStream();
// get template file as InputStream
String filePath = WDURLGenerator.getPublicResourcePath(wdComponentAPI.getDeployableObjectPart(), templateName);
InputStream templateSourceInputStream = new FileInputStream(new File(filePath));
// convert InputStream to OutputStream
IOUtil.write(templateSourceInputStream, templateSourceOutputStream);
templateSourceInputStream.close();
creationContext.setTemplate(templateSourceOutputStream);
ByteArrayOutputStream dataStream = com.sap.tc.webdynpro.clientserver.adobe.api.WDInteractiveFormHelper.getContextDataAsStream(wdContext.nodePDFdata());
creationContext.setData(dataStream);
IWDPDFDocument pdfDocument = creationContext.execute();
res = pdfDocument.getPDF();
} catch (WDPDFDocumentRenderException e) {
wdComponentAPI.getMessageManager().reportWarning(wdContext.currentLabelElement().getMsgErrorRenderingPDF() + ": WDPDFDocumentRenderException - " + e.getLocalizedMessage());
} catch (FileNotFoundException e) {
wdComponentAPI.getMessageManager().reportWarning(wdContext.currentLabelElement().getMsgErrorRenderingPDF() + ": FileNotFoundException - " + e.getLocalizedMessage());
} catch (IOException e) {
wdComponentAPI.getMessageManager().reportWarning(wdContext.currentLabelElement().getMsgErrorRenderingPDF() + ": IOException - " + e.getLocalizedMessage());
} catch (PDFObjectRuntimeException e){
wdComponentAPI.getMessageManager().reportWarning(wdContext.currentLabelElement().getMsgErrorRenderingPDF() + ": PDFObjectRuntimeException - " + e.getLocalizedMessage());
} finally {
return res;
}
//@@end
}
When the ADS server is not well configured or else, you've got the WDPDFDocumentRenderException.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.