cancel
Showing results for 
Search instead for 
Did you mean: 

How to get whole xml data from an online interactive form?

Former Member
0 Kudos

Hi guys,

I noticed there is an PDFObject api, which can extract xml data of an pdf file.

But what we want to do is an online inactive form, which user fill the form online and submit to web dynpro application, then we need to extract the xml data of the pdf embeded in the web dynpro view. I know it is very simple to get very single data of user's input(simply get the context), but my problem is how to get the xml data source of the online form?

I have found any document regarding this scenario, can anybody help me out? Thank you very much!

Regards,

Xiaoming Yang

Accepted Solutions (0)

Answers (3)

Answers (3)

Sigiswald
Contributor
0 Kudos

Hi Xiaoming,

Did you already solve this one?

This is how I extract the data.xml file from a pdf file (I'm using NW2004 SP15):


import com.sap.tc.webdynpro.basesrvc.util.IOUtil;
import org.apache.commons.io.IOUtils;
  private byte[] getData(byte[] pdf) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtil.write(new ByteArrayInputStream(pdf), out);
    IWDPDFObject pdfObject = WDPDFObjectFactory.getPDFObject();
    pdfObject.setPDF(out);
    InputStream in = pdfObject.getData();

    if (in == null) {
      return new byte[0];
    }

    return IOUtils.toByteArray(in);
  }

where I use the <a href="// download from http://jakarta.apache.org/commons/io/">Commons IO</a> library

Kind regards,

/Sigiswald

Former Member
0 Kudos

Hey Sigiswald,

Can you please tell me where did you specify this data.xml in your code?

Thanks

krishanu_biswas
Active Participant
0 Kudos

Hello,

Well, You need to upgrade to atleast SP14 or 15 to make use of that feature. Sp16 is what is already available in the service market place.

I am afraid, otherwise, we do not stand a chance to get the data out of the context. Please let me know if i can be of any help in this regard.

Best Regards,

krish

krishanu_biswas
Active Participant
0 Kudos

Hello Xiaoming Yang,

I am not sure which SP version you are on. If it is atleast SP14 (WebDynpro runtime) then you can use the following code to get the data contained in the data dource context in an XML format:

<b>OutputStream data = WDInteractiveFormHelper.getContextDataAsStream(wdContext.nodeData());</b>

Have a look at the argument. You need to pass on the data source node here. In my case, the data source node name is "Data". Change the parameter accordingly.

You can now manipulate this data stream according to your application requirements.

Best Regatds,

Krish

Former Member
0 Kudos

Hi Krishanu Biswas:

Thank you for your reply, I think you are saying WDInteractiveFormHelper class, but it has only transferPDFDataIntoContext(byte[] pdfSource, IWDNode targetNode) method. Do i misunderstand you?

Anyway, i am trying to use PDFObject and setPDF(outputsteam), the parameter is from the binary context which bind to pdfSource property. But I'm still trying...

Any further comment on this topic will be very appreciated!

Thanks,

Xiaoming Yang