Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 936
  • Last Modified:

Convert xml base64binary to a pdf file

Hi,
I have an xml that contains a pdf in the form of a base64binary in an xml field.
I need to know how to decode the string and convert it back into a pdf?
0
rohan_koudinya
Asked:
rohan_koudinya
  • 4
  • 3
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
try:

Encoding.Default.GetString(System.Convert.FromBase64String(<base64binary_data>))
0
 
Meir RivkinFull stack Software EngineerCommented:
replace <base64binary_data> with the base64binary content from the xml.
0
 
rohan_koudinyaAuthor Commented:
Actually the Data is represented as a byte[] in the code and out of that byte[] i need to put it into a file..
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Meir RivkinFull stack Software EngineerCommented:
to convert byte[] to string:

byte[] myByteArray;
System.Text.Encoding enc = System.Text.Encoding.ASCII;
string myString = enc.GetString(myByteArray);
0
 
rohan_koudinyaAuthor Commented:
[System.Xml.Serialization.XmlAttributeAttribute(DataType="base64Binary")]
    public byte[] InvoiceFile {
        get {
            return this.invoiceFileField;
        }
        set {
            this.invoiceFileField = value;
        }
    }
this is the the field property generated out of the given xml, will your solution fit into this?
0
 
Meir RivkinFull stack Software EngineerCommented:
yes, first convert it to string using my 2nd post, then convert it to regular string using my 1st post.
0
 
rohan_koudinyaAuthor Commented:
Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now