Community
    • Login

    How to convert Encode64 to pdf file using Notepad++?

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 6 Posters 7.8k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ChokkaC Offline
      Chokka
      last edited by

      How to convert Encode64 to pdf file using Notepad++?

      dinkumoilD Alan KilbornA 2 Replies Last reply Reply Quote 0
      • dinkumoilD Offline
        dinkumoil @Chokka
        last edited by

        @Chokka

        What do you mean with “Encode64”?

        1 Reply Last reply Reply Quote 0
        • Alan KilbornA Offline
          Alan Kilborn @Chokka
          last edited by

          @Chokka

          Answer: You don’t.

          1 Reply Last reply Reply Quote 5
          • Prahlad-Makwana4145P Offline
            Prahlad-Makwana4145
            last edited by

            Hello, @Chokka

            Please try this code, To convert Encode64 to PDF file using notepad++ :

            // The Base64 string of a simple PDF file
            var b64 = 'qWbOvwrMwEm+qrA30N6zFIMdzO/mW5zRN44s26ZLnQdSAs8CmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjE5NzExCiUlRU9GCg==';
            
            // Decode Base64 to binary and show some information about the PDF file (note that I skipped all checks)
            var bin = atob(b64);
            console.log('File Size:', Math.round(bin.length / 1024), 'KB');
            console.log('PDF Version:', bin.match(/^.PDF-([0-9.]+)/)[1]);
            console.log('Create Date:', bin.match(/<xmp:CreateDate>(.+?)<\/xmp:CreateDate>/)[1]);
            console.log('Modify Date:', bin.match(/<xmp:ModifyDate>(.+?)<\/xmp:ModifyDate>/)[1]);
            console.log('Creator Tool:', bin.match(/<xmp:CreatorTool>(.+?)<\/xmp:CreatorTool>/)[1]);
            
            // Embed the PDF into the HTML page and show it to the user
            var obj = document.createElement('object');
            obj.style.width = '100%';
            obj.style.height = '842pt';
            obj.type = 'application/pdf';
            obj.data = 'data:application/pdf;base64,' + b64;
            document.body.appendChild(obj);
            
            // Insert a link that allows the user to download the PDF file
            var link = document.createElement('a');
            link.innerHTML = 'Download PDF file';
            link.download = 'file.pdf';
            link.href = 'data:application/octet-stream;base64,' + b64;
            document.body.appendChild(link);
            

            I hope above code will be useful for you.
            Thank you.

            Olivier De GroefO 1 Reply Last reply Reply Quote -1
            • Olivier De GroefO Offline
              Olivier De Groef @Prahlad-Makwana4145
              last edited by

              What is the programming language of this? Is this java/JS/groovy or some other language ?
              How should be run this?

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP Offline
                PeterJones @Olivier De Groef
                last edited by

                @Olivier-De-Groef ,

                The script you are replying to, from four years ago, has nothing to do with Notepad++.

                It appears it might be javascript intended to be run in the browser, but I wouldn’t run it without fully understanding the code. (I tried to base64-decode the string that the script supplied, for example, but it doesn’t end up starting with the bytes %PDF, so I am pretty sure it doesn’t decode into a PDF file like it purported to doing; as such, I really wouldn’t trust anything in that script.)

                The right answer to the 2019 question is the one Alan gave in 2019: “you don’t”.

                PDF is a binary format, not a text format, and Notepad++ is a text editor.

                => FAQ

                1 Reply Last reply Reply Quote 2

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors