on 06-02-2009 7:06 AM
Hello,
I'm developping an application where I'm supposed to generate PDF documents, and I have a few questions about that.
what is the best way to generate pdf document in a Web Dynpro application besides Interactive forms?
I have a double situation. In the first scenario the user can choose a specific case,preview the data in pdf, maybe adjust the data and generate the pdf document. This I can do with Interactive forms. But in a second scenario the user can just choose "generate pdf" and a seperate pdf document should be generated for all the cases.
what java tools can I use for this second scenario? can I use a template or something from the interactive form to generate the same pdf layout in both cases to preserve the consistency in layout?
all kinds of help will be much appriciated.
Thanks in advance.
Alperen
Hi Alperen,
For your second scenario: if you want to maintain consistent layout for all cases you can use the same xdp template and generate the pdf file.
Using following API you can set the data and template dynamically.
//use this code to change the data dynamically for all cases.
String dataString = "<MyDataModel> <name>xyz</name><age>26</age><address-city>Hyd</address-city><address-state>IN</address-state></SAPDataModel>";
byte dataBytes [] = dataString.getBytes();
byte templateBytes[] = new byte[1024];
IWDPDFDocumentHandler hndlr = WDPDFDocumentFactory.getDocumentHandler();
IWDPDFDocumentCreationContext cxt = hndlr.getDocumentCreationContext();
cxt.setData(dataBytes);
String resourcePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "datatest.xdp");
wdComponentAPI.getMessageManager().reportSuccess(resourcePath);
BufferedInputStream buffInStream = new BufferedInputStream(new FileInputStream(resourcePath));
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
int readLength = 0;
while((readLength=buffInStream.read(templateBytes))>0)
{
byteOutStream.write(templateBytes,0,readLength);
}
cxt.setTemplate(byteOutStream);
IWDPDFDocument document = cxt.execute();
//use the document object to show the data.
You can design the form layout outside and copy the xdp file to src > mimes > Components > yourpackage
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to create two separate templates one with interactive features other with just read only information i.e. using text view elements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
I have been looking in the presentations and tutorials you have linked me to before. however I haven't found anything that would match my requirements. am I overlooking something? can you be more specific?
what I want in my second scenario is without opening any interactive forms, generate a series of pdf's with data from the context.
Regards,
Alperen
Hi Alpern,
As per my knowledge you have to use interactive forms when you want to show some context data in PDF files in webdynpro.
But if you dont want to use interactive forms, then you have to look for third party api's(jars) which can be used in webdynpro and fulfil your requirement.
Regards,
Saleem.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.