PHP get pdf file from base64 encoded data string

Try this piece of code $pdf_base64 = “base64pdf.txt”; //Get File content from txt file $pdf_base64_handler = fopen($pdf_base64,’r’); $pdf_content = fread ($pdf_base64_handler,filesize($pdf_base64)); fclose ($pdf_base64_handler); //Decode pdf content $pdf_decoded = base64_decode ($pdf_content); //Write data back to pdf file $pdf = fopen (‘test.pdf’,’w’); fwrite ($pdf,$pdf_decoded); //close output file fclose ($pdf); echo ‘Done’;

Base64: java.lang.IllegalArgumentException: Illegal character

Your encoded text is [B@6499375d. That is not Base64, something went wrong while encoding. That decoding code looks good. Use this code to convert the byte[] to a String before adding it to the URL: String encodedEmailString = new String(encodedEmail, “UTF-8”); // … String confirmLink = “Complete your registration by clicking on following” + “\n<a … Read more

Write Base64-encoded image to file

Assuming the image data is already in the format you want, you don’t need ImageIO at all – you just need to write the data to the file: // Note preferred way of declaring an array variable byte[] data = Base64.decodeBase64(crntImage); try (OutputStream stream = new FileOutputStream(“c:/decode/abc.bmp”)) { stream.write(data); } (I’m assuming you’re using Java … Read more

Convert long integer(decimal) to base 36 string (strtol inverted function in C)

There’s no standard function for this. You’ll need to write your own one. Usage example: https://godbolt.org/z/MhRcNA const char digits[] = “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”; char *reverse(char *str) { char *end = str; char *start = str; if(!str || !*str) return str; while(*(end + 1)) end++; while(end > start) { int ch = *end; *end– = *start; *start++ = … Read more

How to parse into base64 string the binary image from response?

I think part of the problem you’re hitting is that jQuery.ajax does not natively support XHR2 blob/arraybuffer types which can nicely handle binary data (see Reading binary files using jQuery.ajax). If you use a native XHR object with xhr.responseType=”arraybuffer”, then read the response array andĀ convert it to Base64, you’ll get what you want. Here’s a … Read more