Forum Moderators: open

Message Too Old, No Replies

Converting a Base64 encoded String from XML to a GIF

UPS Online Tools getting the Label Image

         

mrdougb

5:02 am on Jul 3, 2003 (gmt 0)

10+ Year Member



Hello,
I am having a heck of a time trying to integrate with the UPS shipping online tools. Everything was going great, until I tried to get the label returned from UPS. UPS returns in the XML response a Base 64 encoded graphic image. I am having problems converting this string into a GIF image. I have tried multiple ways of doing it and none have worked. Does anyone know how to do this? Any help or hints would be greatly appreciated. Thanks a lot!

Here's the latest I have:

Dim bytValue() As Byte 'an array of bytes
Dim encodedstring As String 'the incoming string Image

encodedstring = elemList(indx).ChildNodes(2).InnerText
encodedstring = bs64.DecodeStr64(encodedstring) 'this is a function supplied by UPS to decode the string, if I use the .NET convert.fromBase64String I get a "Invalid character in a Base-64 string." error, which makes me suspicious
Dim f As File
Dim fs As FileStream
fs = f.Create(SamplePath & drDetail.strTrackingNumber & ".gif") 'create the file
Dim w As New BinaryWriter(fs)
w.Write(encodedstring)
w.Close()

I have also tried using byte arrays and writing to the file with those, and my image still isn't correct.

Xoc

2:31 pm on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You said "graphic image", but you didn't say GIF. Is it possible that the format is a bitmap?

mrdougb

2:38 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



Nope, it's definitely a GIF. You get 2 options when requesting the label from UPS; either a GIF or an EPL2. The GIF is mainly using in web browser applications and the EPL2 is for business applications for thermal printers.