cancel
Showing results for 
Search instead for 
Did you mean: 

pdf document generation

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member182294
Active Contributor
0 Kudos

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

Former Member
0 Kudos

thank you Abhilash,

this looks like what I was looking for. I will definetly try this. would be great if I can get this to work.

Regards,

Alperen

Answers (1)

Answers (1)

Former Member
0 Kudos

You have to create two separate templates one with interactive features other with just read only information i.e. using text view elements.

Former Member
0 Kudos

Hi,

You need to use Online & Offline interactive forms for your requriement. There is no need of any external api or jars.

See the presentations & tutorials on SAP Interactive Forms by Adobe in the below link.

[original link is broken]

Regards,

Charan

Former Member
0 Kudos

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

Former Member
0 Kudos

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.