Dark_Tower
12th December 2006, 07:57
Hi, I am modifying the QPrinter engine for the generation of Pdf because I want to include the original image file in the PDF and not a re-compressed copy of the image. The image written in a PDF is saved in a QByteArray compressed. The original code is the following:
QBuffer buffer(&imageData);
QImageWriter writer(&buffer, "jpeg");
writer.setQuality(94);
writer.write(img);
where "img" is the QImage to write on the PDF doc and "imageData" is the QByteArray that will be fisically written in the PDF doc calling to "writeImage". Well, I want to change the code above with the following:
QFile fitxerImatge(pathImatge);
imageData = fitxerImatge.readAll();
where "pathImatge" is the path to the original image file. The problem is that no images are written in the PDF doc with the second code and when I openit with Adobe Acrobat Reader it says that "There isn't enough data for the image". I've checked that the path is correct and, moreover, the original image file contains a JPEG image created with Qt. So, I don't know where's the problem. Could you suggest me something, please?
QBuffer buffer(&imageData);
QImageWriter writer(&buffer, "jpeg");
writer.setQuality(94);
writer.write(img);
where "img" is the QImage to write on the PDF doc and "imageData" is the QByteArray that will be fisically written in the PDF doc calling to "writeImage". Well, I want to change the code above with the following:
QFile fitxerImatge(pathImatge);
imageData = fitxerImatge.readAll();
where "pathImatge" is the path to the original image file. The problem is that no images are written in the PDF doc with the second code and when I openit with Adobe Acrobat Reader it says that "There isn't enough data for the image". I've checked that the path is correct and, moreover, the original image file contains a JPEG image created with Qt. So, I don't know where's the problem. Could you suggest me something, please?