Decode base64 into PDF file
I have a PDF file which has been encoded to base64. Now I want to convert these base64 script and write to a file to make a PDF file, I have try as following code:
Code:
QFile file("output.pdf");
out << data;
file.close();
It can create the PDF file but it can not be read, the Foxit Reader say that "format error". I check the data has been decoded and I found that some special character become "?". How could I get all the character out? Could anyone can give me a solution?
Re: Decode base64 into PDF file
QTextStream is for streaming textual data. PDF is binary data so it is not suited for QTextStream. Use QFile::write() instead.
Re: Decode base64 into PDF file
Quote:
Originally Posted by
wysota
I use QFile::write() but it still error and I try QDataStream instead, it works fine now. Thank you!
Re: Decode base64 into PDF file
... then you are doing it wrong. If QDataStream::writeRawData() works then QIODevice::write() must work: the former being a thin wrapper over the latter.