cancel
Showing results for 
Search instead for 
Did you mean: 

Download Interactive Form

Former Member
0 Kudos

Hello!

Can an Interactive Form be generated without displaying it?

I want to ge hold of the pdfContent byte[], but don´t want to display the form.

Thank you!

Ilona Seifert

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ilona,

You can try with the following:

-


import com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api.IWDPDFDocument;

import com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api.IWDPDFDocumentCreationContext;

import com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api.WDPDFDocumentFactory;

import com.sap.tc.webdynpro.basesrvc.util.IOUtil;

...

InputStream template = ... //your XDP file as an inputstream

String xmlData = ... //business data you want to merge your form template with

ByteArrayInputStream dataSourceInputStream = new ByteArrayInputStream(xmlData.getBytes());

ByteArrayOutputStream dataSourceOutputStream = new ByteArrayOutputStream();

ByteArrayOutputStream templateSourceOutputStream = new ByteArrayOutputStream();

// convert InputStream to OutputStream

IOUtil.write(template, templateSourceOutputStream);

IOUtil.write(dataSourceInputStream,dataSourceOutputStream);

IWDPDFDocumentCreationContext creationContext = WDPDFDocumentFactory.getDocumentHandler().getDocumentCreationContext();

creationContext.setTemplate(templateSourceOutputStream);

creationContext.setData(dataSourceOutputStream);

creationContext.setDynamic(true); //if you want to create dynamic interactive form

IWDPDFDocument pdfDoc = creationContext.execute();

// create the PDF and store it as ByteArrayInputStream

InputStream pdfInputStream = pdfDoc.getPDFAsStream();

Best Regards,

Ferenc

P.S.: If you use some older version and the "com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api" package is not available for you, then you can do the same with the old "com.sap.tc.webdynpro.pdfobject.api" package

Former Member
0 Kudos

Hello Ferenc,

thank you for your answer. I´ll need some time to investigate this.

Best Regards

Ilona

Former Member
0 Kudos

Hi Ferenc ,

I have tried your code but Download link is appeared but when i cliecked on that but no result.

Please help me to trace out this code.

Regards,

Gurprit Bhatia

Former Member
0 Kudos

hi,

Can you brief me what exactly you are trying to do in your application.

I mean if you do not want to generate the PDF then what are you trying to do.

Thanks,

kris

Former Member
0 Kudos

Hello Kris,

I want to download an interactive form, but do not want to display it on the screen. Currently my pdf is generated when clicking a button, which fires a plug to a new view and displays the interactive form.

Instead I want to use a FileDownload Element, which refers to the pdfSource context attribute, but currently the bytecode is only generated when displaying the output on the screen.

If I set the visibility of my Interactive Form to blank or none, no pdfSource byteCode is generated.

I hope I made my problem clear.

Thanks, Ilona

Former Member
0 Kudos

hi,

Generally the Filedownload is used when trying to call a PDF that is being saved in the location

\src\mimes\Components\<Application Name>\<your PDF file>

So I suppose this feature is not possible where you are trying to directly pop up a screen asking for open/save/cancel the PDF.

setting visibility would not work in this case.

Thanks,

kris