You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Gundala, Jagannadha" <Ja...@bankofamerica.com> on 2005/04/06 19:18:30 UTC

Urgent help required

Hi , 

   I have a xml schema and I could be able to successfully create a .jar
file using scomp. In my input xml document , there is tag that has
binary data. My job is to extract this binary data and save it to a PDF
file.

   I am using a SOAP decoder which is Base64 for decoding. Here is the
code snippet.

 

    FileOutputStream out1 = new FileOutputStream("C:\\SaiRam.pdf");

 

    String comments   =
dataDoc.getDataCommunication().getTransaction().getDocumentArray(i).getC
omments();

  System.out.println(comments);

  String docName    =
dataDoc.getDataCommunication().getTransaction().getDocumentArray(i).getD
ocumentName();

  System.out.println(docName);

  String docType    =
dataDoc.getDataCommunication().getTransaction().getDocumentArray(i).getD
ocumentType();    

  System.out.println(docType);

  if (docType.equals("PDF")) {  

      System.out.println("Yes it is pdf");

      //Object obj =
dataDoc.getDataCommunication().getTransaction().getDocumentArray(i).getC
ontent();

      byte[] byteArry  =
dataDoc.getDataCommunication().getTransaction().getDocumentArray(i).getC
ontent().getByteArrayValue();

      //System.out.println("Value before decode as byte array  : " +
byteArry);

      String baseImage = new String(byteArry);

      //System.out.println("Value before decode as String  : " +
baseImage);

      p1 = new PrintStream(out1);

      p1.println(Base64.decode(baseImage));

      p1.close();

  } 

  

  I can see a pdf file created but while opening this file, it is
complaining that file may be corrupted or not decoded properly.

 

   Here are my questions on this and any help will be greatly
appreciated. 

   

1.    The byte array is created by xml beans api and I am using SOAP
Decoder for decoing this binary data. Is this Ok or should I use 

a different decoder that complies with xml beans.

      2. I noticed at the time of decoding, we are not specifying if it
has to be decoded for pdf or for any type of file.

 

Regards,

Jag