locked
How can I display Base64 encoded pdf data with in Windows 8 Application

    Question

  • Hi,

    I have a requirement to show Base64 encoded string as PDF view with in the application. I am using iframe to show PDF,which is working other environments (like iOS). I saw support to display an local PDF file with PDF viewer in Windows 8.

    1) Is there any possibility to display base64 string as PDF, inside the app.

    2) And, How Can I convert base64 string to PDF file and show it with Windows 8 default PDF viewer.

    Friday, September 26, 2014 10:24 AM

Answers

  • Decode the Base-64 string, save as PDF, then load that?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Theja Dasari Monday, October 06, 2014 11:13 AM
    Friday, September 26, 2014 12:47 PM
    Moderator

All replies

  • Decode the Base-64 string, save as PDF, then load that?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Theja Dasari Monday, October 06, 2014 11:13 AM
    Friday, September 26, 2014 12:47 PM
    Moderator
  • This is the code for my requirement

    var iBuffer = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(base64Data); var fileBytes = Windows.Security.Cryptography.CryptographicBuffer.copyToByteArray(iBuffer); var folder = Windows.Storage.ApplicationData.current.localFolder; folder.createFileAsync("page.pdf",

    Windows.Storage.CreationCollisionOption.replaceExisting).then(function (dummyFile) { return Windows.Storage.FileIO.writeBytesAsync(dummyFile, fileBytes); }).done(function () {

    folder.getFileAsync("page.pdf").then(function (file) { var options = new Windows.System.LauncherOptions(); options.displayApplicationPicker = false; // Launch the retrieved file using the selected app Windows.System.Launcher.launchFileAsync(file, options).then( function (success) { if (success) {

    // File launched

    }

    else {

    // File launch failed

    } }); }); });





    Monday, October 06, 2014 11:21 AM