cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading PDF File generated by interactive form element

Former Member
0 Kudos

Hi,

I am generating a PDF form using interactiveform element and displaying in a separate view. Is it possible to download the same generated form instead of displaying in view?

Please sugest me on this.

Thanks,

Raz

Accepted Solutions (1)

Accepted Solutions (1)

former_member194668
Active Participant
0 Kudos

Hi Raz,

Try this...

1. Create a context attribute(res) of type com.sap.ide.webdynpro.uielementdefinitions.Resource

2. Insert a file download ui control and bind the property resource to the above attribute

3. you must have defined a pdfSource of type byte[], using that populate the 'res' attribute

IWDResource res = WDResourceFactory.createResource(wdContext.currentContextElement().getPdfSource(),"",WDWebResourceType.PDF);
    wdContext.currentContextElement().setRes(res);

-Aarthi

Former Member
0 Kudos

Hi Aarthi,

The PDF Source is of type binary, can you please suggest me how to convert it to byte array?

Thanks,

Raz

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Use this following code in any button action, then you will be seen a popup window to download the pdf from resource path

Hope

IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal()),

resource.getResourceName());

window.show();

Hope you have pdf in IWDCachedwebResource

Regards

Raghu

Former Member
0 Kudos

Hi Raghu,

Thanks for the sollution. But I need your help in preparing the PDFsource(binary) of interactive form element into IWDCachedwebResource.

Please help me out in this.

Thanks,

Raz

former_member194668
Active Participant
0 Kudos

The way I've created resource from pdf source works perfectly.

Check again.

-Aarthi

Former Member
0 Kudos

Aarthi,

How did you prepared PDF source? Can you please explain me that?

Thanks,

Raz

former_member194668
Active Participant
0 Kudos

pdfSource is of type 'Binary'

Former Member
0 Kudos

Hi Aarthi,

Thanks for your patience. I am getting the fallowing runtime error when I am executing. I wrote the code in wdinit() specified by you.

java.lang.NullPointerException

at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)

at com.sap.tc.webdynpro.progmodel.mime.UploadResource.<init>(UploadResource.java:30)

at com.sap.tc.webdynpro.progmodel.mime.ResourceFactory.createResource(ResourceFactory.java:104)

at com.sap.tc.webdynpro.progmodel.api.WDResourceFactory.createResource(WDResourceFactory.java:58)

at com.greenheck.orderstatus.PDFView.wdDoInit(PDFView.java:130)

Thanks,

Raz

former_member194668
Active Participant
0 Kudos

pdf might not be generated in the init method itself.

try to invoke the mentioned code in an action, after the pdf is generated.