PDA

View Full Version : Save PDF to BLOB



wirasto
22nd May 2009, 09:28
Dear all,

Could anyone tell me is any way to save PDF files to MySQL (BLOB), and open BLOB as PDF in Qt Widget ?

Thank's

tpf80
24th May 2009, 06:47
All you have to do to save any file to a blob, is to read it into a QByteArray using QFile and then use QSqlQuery with a sql insert instruction binding that QByteArray to the blob field.

As for displaying it in a widget, you might need to find some kindof library that can read the PDF and make a widget that can display it (such as this (http://doc.trolltech.com/qq/qq27-poppler.html)).

Often, people read it back from the SQL into a QByteArray, have QFile save it to a temp file, and use QDesktopServices to make the operating system's default viewer open it.