cancel
Showing results for 
Search instead for 
Did you mean: 

How can we use mode "UsePDF" in Interactive form?

Former Member
0 Kudos

Hello everybody,

I want to know that how can i use the mode usePdf in Interactive form?

My scenario is:

I have pdf form saved locally with blank fields.

I save this file after requied values in all fields.

Now i want to import this pdf file in interactive form and needs to submit this form so all the data in this pdf file are submitted to the System.

How can i do this?

regards,

Bhavik

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member705496
Discoverer
0 Kudos

Hi Bhavik,

you have to use the upload UI-element in Web Dynpro, in order to upload the locally filled out form (a download/upload form tutorial will be available soon within SDN) into your Web Dynpro application.

If you then want to display the uploaded form before submitting the contained data, you have to use the interactive form UI-element. The pdfSource attribute (corresponds to a byte-Array) of this UI-element should be the one you used for the upload UI-element. Set the mode attribute to usePDF. If the context which corresponds to the dataSource matches with the form, then after uploading the form the data will reside in the context for further processing.

If you do not want to display the data before submitting the data, then you have to use the WDInteractiveFormHelper class for extracting the form data after upload in the context. This class is available since NetWeaver04 Support Package Stack (SPS) 10.

Regards, Carsten

Former Member
0 Kudos

Hi Carsten,

Thanks for your reply. After a long time i recieve reply on this topic.

What i have done in my application is, I am reading the binary data of the PDF file from the coding only instead of Upload UI element using Fileinputstream. and then bind this Binary data to the Interactive UI element.

I have also set Mode to UsePDF.

But at runtime, It is showing only the blank screen.

So, what could be the reason behind this? Should i have to use Upload UI element only to achieve this?

And for second alternative, what this WDInteractiveFormHelper class does excatly? and how can we use this class in our code?

Thanks,

Bhavik

Former Member
0 Kudos

Hello everybody,

This problem is resolved by using upload UI Element instead of fetching binary data directly from the PDF file.

I dont know the difference between this two.

anyway now its working atleast partially.

Thanks to all,

Bhavik

former_member705496
Discoverer
0 Kudos

Hi Bhavik,

you do not need to use the upload ui element, if your pdf-file which you want to upload resides in you web application project. In the following you can find Web Dynpro code snippets I use in one of my demos for displaying an uploaded pdf-file:

wdDoModifyView method of FormView:

-


//@@begin wdDoModifyView

try {

// get interactive form element by ID

InteractiveForm form = (InteractiveForm) view.getElement("Evaluation");

if (wdContext.currentContextElement().getCurrentMode().equals("usePDF")) {

form.setMode(WDInteractiveFormMode.USE_PDF);

}

}

catch (Exception e) {

e.printStackTrace();

}

//@@end

onPlugFromUploadView method of UploadView:

-


//@@begin onPlugFromUploadView(ServerEvent)

try {

// modify the context and set needed attributes

wdContext.currentContextElement().setCurrentMode( "usePDF" );

// extend the attribute "pdfSource" from the context to a modifiable binary type

IWDAttributeInfo attInfo = wdContext.currentContextElement().node().getNodeInfo().getAttribute("pdfSource");

ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;

binaryType.setFileName("evaluationForm.pdf");

binaryType.setMimeType(WDWebResourceType.PDF);

// add the generated pdf to the context

wdContext.currentContextElement().setPdfSource( evaluationForm ); // byte[] evaluationForm

}

catch (Exception e) {

wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());

}

//@@end

If you do not want to display the data before submitting the data, then you have to use the WDInteractiveFormHelper class for extracting the form data after upload in the context. This class is available since NetWeaver04 Support Package Stack (SPS) 10. The class com.sap.tc.webdynpro.clientserver.adobe.api.WDInteractiveFormHelper contains at the moment one helper function for PDF document. Here are the details:

Constructor Detail

-


public WDInteractiveFormHelper()

Method Detail

-


public static void transferPDFDataIntoContext(byte[] pdfSource, IWDNode targetNode)

Method transferPDFDataIntoContext extracts data from a PDF document and copies the values into the Web Dynpro Context. The xml structure of the document data is applied starting from the specified target node. Usually, this node should be the same context node to which InteractiveForm-UIELement property dataSource is bound during PDF generation.

Parameters:

pdfSource - PDF document as byte[]

targetNode - target IWDNode

Hope this will help you,

Regards, Carsten

Former Member
0 Kudos

Hi Carsten,

Thank you very much.

I understood most of the things. But can't understand what is the evaluationForm? I guess its of type byte[]. but from where you populated data in this variable?

What i have done is,

In init method of my one of the views i have written following code.

try{

File file = new File("c:
create_emp.pdf");

FileInputStream fi = new FileInputStream(file);

byte[] data = new byte[fi.available()];

fi.read(data);

fi.close();

wdContext.currentContextElement().setPdfSource(data);

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException("Error : "+e.getMessage(),true);

}

Here, file named create_emp.pdf is available on server under c drive. It is generated pdf by ADS only. So, data source also bound properly for this.

So, after reading binary data from this file, I set this binary data to the context variable pdfSource type of binary. This context attribute is bound to the InteractiveForm element.

But still its not working.

What could be the resion behind this?

Thanks,

Bhavik

Former Member
0 Kudos

Bhavik,

did you solved the issue?

Regards

Former Member
0 Kudos

Hi Bhavik,

I am not sure about Interactive Forms, but what i am working on is to take a filled PDF form from the user and upload it to R/3. In the code i am performing activity on the pdf by extracting its xml file and then setting it back into the pdf before sending it back to R/3.

I am making certain ADS calls like createPDF(),setPDF() methods.

I guess a part of this may be useful to you.

Thanks and regards,

Jitendra.