nhocjerry
30th July 2013, 12:32
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:
QByteArray data = QByteArray::fromBase64(ui->txtData->toPlainText().toAscii());
QFile file("output.pdf");
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
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?
QByteArray data = QByteArray::fromBase64(ui->txtData->toPlainText().toAscii());
QFile file("output.pdf");
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
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?