I need to create file from data in SQL. I have base64 string in SQL. I have no problem with images. But the problem is with PDF or XLS files. I use code:
$base_64 = 'GENERATE SOME BASE_64 CODE FROM SQL';
file_put_contents('myFile.pdf', base64_decode($base_64));
I need help?
You can't insert it directly into a PDF. You have to use a TCPDF like library: http://www.tcpdf.org/index.php
You can checkout the examples here: http://www.tcpdf.org/index.php
TCPDF Works quite easy. you should try it!
It should work, your code seems ok. Make sure your SQL table isn't stripping your base64 code.
file_put_contents
works PERFECTLY FINE with pdf files
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.