Encoded .docx to Base64String then Decode to .pdf got error RRS feed

  • Question

  • The base64 string was encoded from a .docs file. When I decoded the base64 string to .pdf, I got this error: "Adobe Acrobat Reader could not open '' because it is either not a supported file type of because the file has been damaged (for example, it was sent as email attachment and wasn't correctly decoded).

    Encoding code:

    byte[] file = ......
    string base64String = Convert.ToBase64String(file);

    Decodeing code:

    string base64EncodedData = System.IO.File.ReadAllText(@"C:\Temp\Base64String.txt");
    var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
    File.WriteAllBytes(@"C: \Temp\Base64StringOut.docx", base64EncodedBytes);

    The Base64String.txt contains the string that was encoded from a .docx file.

    I am not sure if the encoding was incorrect or the decoding was incorrect. Any help is appreciated. 


    • Edited by danyeungw Thursday, July 26, 2018 10:01 PM
    Thursday, July 26, 2018 7:45 PM


  • If the original file is .DOCX, it will still be .DOCX when you decode it. (Much like when you Zipped a .DOCX file and unzip the file later, you don't expect it to become a .PDF file)

    Why would you expect Adobe Acrobat Reader to be able to open it?

    Find some convertors to do the conversion, or correctly name the file as "*.docx" and ask the user open it with MS Word or open it with Office Online.

    • Edited by cheong00Editor Friday, July 27, 2018 2:18 AM
    • Marked as answer by danyeungw Friday, July 27, 2018 3:45 AM
    Friday, July 27, 2018 2:16 AM