[Solved] Difference between Qt4.8 and Qt5.0 when print pdf
Hi, I had a little code in Qt4.8 used to make a pdf file with barcodes and to print in cards (like credit cards).
When my pc died, I installed Qt5.0, adding printsupport and other few modification not related with QPrinter o QPainter.
No problem to compile or run in Qt5, but the file output it's diferent, (see the picture), making an invalid barcode.
Well, can somebody tell me why the output differ between Qt4.8 and Qt5?
Thanks in advance.
@mm = 11.8;
QStringList path = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
QString home = QFileInfo(path.at(0)).absoluteFilePath();
QString tarjFile = tr("tarjetas_%1.pdf").arg(fecha.currentMSecsSinceEpoch());
QString outputPdf = tr("%1/%2").arg(home).arg(tarjFile);
printer.setPaperSize(QSize(85.6, 54), QPrinter::Millimeter);
printer.setPageMargins(0.0, 0.0, 0.0, 0.0, QPrinter::Millimeter);
QFont fontC("3 of 9 Barcode", 16);
tarjeta = ("1234567890123456");
painter.drawText(QRect(0, 5mm, 85.6mm, 5*mm), Qt::AlignHCenter, tarjeta);
This font: http://www.dafont.com/3of9-barcode.font
int main(int argc, char **argv)
QApplication app(argc, argv);
QFontDatabase::addApplicationFont("3OF9_NEW.TTF"); const int mm = 11.8; QPrinter printer; printer.setOutputFileName("test.pdf"); printer.setOutputFormat(QPrinter::PdfFormat); printer.setPaperSize(QSize(85.6, 54), QPrinter::Millimeter); printer.setResolution(300); printer.setColorMode(QPrinter::Color); printer.setPageMargins(0.0, 0.0, 0.0, 0.0, QPrinter::Millimeter); printer.setFontEmbeddingEnabled(true); QPainter painter; painter.begin(&printer); QFont fontC("3 of 9 Barcode", 16); painter.setFont(fontC); painter.drawText(QRect(0, 5*mm, 85.6*mm, 5*mm), Qt::AlignHCenter, "0123456789012345"); painter.end(); return 0;
This result with Qt 4.8.4 (top) and Qt 5.0.1 (bottom) on Linux:
Differences are fairly subtle.
Thanks for reply.
I can't see your picture, but I tried with several fonts, using directly from windows's (xp) fonts and adding with QFontDatabase::addApplicationFont(). Same result.
Recently, I try print barcode using LibreOffice on windows and it works (when I say "it works", is: the bardcode reader can read it and decode)
This is the barcode on LibreOffice
!https://imageshack.us/a/img199/7908/3of9libreoffice.png(barcode on LibreOffice)!
Well, like the problem it's at pdf generation in Qt, but why? or where?
Have you tried to "file a bug report":https://bugreports.qt-project.org/ ? Adding a minimum working example like the one you gave here helps a lot:)
Bugreports do end up at the desk of the people that work on the relevant sub-system. They have to stumble over the issue by accident here in the forums.
Hi Tobias. Thanks for your reply.
Well, not really, before send a bug report I try always deplete all option to find a solution. (I'm not acquainted with bug report too) But, I'll try to report this as a bug.
I've uploaded the original image to another host. Maybe you can see it now.
Here is a Windows XP version of the same (4.8.0 top, 5.0.1 bottom):
!http://img401.imageshack.us/img401/761/testpages.png(On Win XP)!
So the problem is Windows (or XP) specific.
Yes, I can see it now, and effectively, it's like a problem in windows and Qt5. Lines in the barcode are wider than in Qt4.8.
As Tobias recommended, I did a bug report, now let's wait..
I did wonder it if is some curious text anti-aliasing glitch