Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

xml file with pdf attachment

Hi,

Anybody knows how to extract the pdf file which is an attachment in a xml file? We are getting a xml file in which pdf data comes as an attachment. We are currently using vb.net.

Thanks in advance
RAM

RAM
Friday, February 28, 2003

A PDF attachment in an XML file? I'm guessing the PDF will be Base64-encoded into part of the Xml document (rather than using DIME...).

Therefore, read the InnerText of the XmlNode in question, and convert this Base64-encoded string into a Byte array using the System.Convert.FromBase64String() method. This can then be written to a file using an instance of System.IO.FileStream, specifically the Write() method. Remember to Close() the FileStream, and you should have hopefully "rehydrated" the PDF document.

Duncan Smart
Friday, February 28, 2003

Thanks a lot. System.Convert.FromBase64String() is what we needed and it worked perfectly fine in our case. We are getting MS-Word and MS-Excel files too as attachments and we are working on that.

Thanks again
RAM

RAM
Monday, March 03, 2003

It seems that both MS-WORD and PDF attachments are working fine but not MS-Excel. When we decode the content(which was origionally encoded by different program) and write that into corresponding files(if it is a pdf attachment, write it as a pdf file) The Excel file has more than one sheet and could that be a problem?

Any input is highly appreciated

RAM

RAM
Tuesday, March 04, 2003

"MS-WORD and PDF attachments are working fine but not MS-Excel" -- well, what's (not) happening? Is it being written to a file OK - but Excel won't open it? Is the FromBase64String() failing... or what?

Duncan Smart
Thursday, March 06, 2003

Hi,

I Guess writing into Excel file is failing. We can see the Excel file getting generated but could not open. Lately we found out it happens only for one particular Excel file as all others are working fine. Still trying to figure out!! but we don't have any control in source xml file which comes with attachments. So until it happens again, we are helpless!!

Thanks for your response on this

RAM

RAM
Monday, March 10, 2003

*  Recent Topics

*  Fog Creek Home