Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default Unanswered: writing file from binary string problem

    Unanswered: writing file from binary string problem


    hello guys,

    i'm creating a pdf document and have the base64 string. i decode the string to a binary string and save the document with the ion writefile function but on saving it will change mutation letters like Ä, Ö, Ü (würzburg).

    But when i copy the binary string from the console and past it into a file it will not change.

    Code:
    var byteString = atob(pdf.getBase64Text());                            
    console.log(byteString);
    Ion.io.writeFile(Ion.io.tempPath + 'test.pdf', byteString);
                                
    Ion.util.openUrl('file:' + Ion.io.tempPath + 'test.pdf');
    kind regards
    malfurion

  2. #2
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
    Answers
    20
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    Is the byteString a "String" or a Number[] (array of numbers/bytes)? If the data being passed is a String, we automatically decode the string from the JavaScript UTF-16 representation into a UTF-8 encoding for writing to disk. When it's a Number[], we take each number as an unsigned 8-bit integer and write it directly to disk in binary form.

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default


    the byteString is a 'String' not a Number Array

  4. #4
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default


    Hey guys,


    we have a big problem with the Ion.io.writeFile() Method.


    We have a bas64 string and try to save it with your Ion.io.writeFile() method.
    The pdf looks like (see screenshot) and we spend about 5 days to fix this problem by ourselvs.


    The code is:
    Code:
    var dataUTF8 = unescape(encodeURIComponent(pdf.getBase64Text()));
    var dataBINARI = window.atob(dataUTF8); // we also tryed it without window.
    Ion.io.writeFile(Ion.io.tempPath + 'test.pdf', dataBINARI);                            
    Ion.util.openUrl('file:' + Ion.io.tempPath + 'test.pdf');
    2013-01-01 16_13_04-test.pdf - Adobe Reader.png

    If we use the latest Chrome with this code:
    Code:
    var theUrl = 'data:application/pdf;base64,' + pdf.getBase64Text();
    window.open(theUrl, '_blank');

    the pdf is generated properly (see second screenshot)!

    2013-01-01 16_10_11-data_application_pdf;base64,JVBERi0xLjQNCjEgMCBvYmoNCjw8L1RpdGxlIChTYW1wbGUg.png

    So what are we doing wrong??

    sincerly steffen(DOT)brunner[AT]itizzimo(DOT)com

  5. #5
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default


    Hello guys,

    I have fixed the problem i have find a way to convert the base64 to an numeric array


    Kind regards
    Malfurion

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    22
    Vote Rating
    0
    Mark Dyer is on a distinguished road

      0  

    Default


    Quote Originally Posted by malfurion559 View Post
    Hello guys,

    I have fixed the problem i have find a way to convert the base64 to an numeric array


    Kind regards
    Malfurion
    Glad to hear you found a solution. Would you mind posting how you did it?

Thread Participants: 2