[Interest] PDF to QByteArray

Jason H scorp1us at yahoo.com
Fri Feb 28 05:13:00 CET 2014


Make sure you open the file in binary mode. PS files are text, PDFs have both text and binary modes. Default is binary.

QFile f("file.pdf");
QByteArray ba;

if (f.open (QIODevice::ReadOnly))
{
   ba = file.readAll();
}

Should be all you need.




________________________________
 From: Marcelo Estanislau Geyer <estanisgeyer at hotmail.com>
To: "interest at qt-project.org" <interest at qt-project.org> 
Sent: Thursday, February 27, 2014 8:58 PM
Subject: Re: [Interest] PDF to QByteArray
 




So that they can understand, I need to put the contents of a pdf file into a QByteArray, as this QByteArray is used as an attachment in the email sending process.

I did a test with a postscript file (.ps file) and it worked perfectly. I only have this problem with pdf files.
How can I read and properly store the content (binary) of a pdf file into a QByteArray?


_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140227/cea8e2fb/attachment.html>


More information about the Interest mailing list