Print error on page (qtWebkit)
Asked Answered
Q

1

7

Bug in Qt5.2.1:

The only problem was corrected in QPrintPreviewDialog but when the print is printed on paper the failure still exists.

With QPrintPreviewDialog pages work perfect, but on "paper" (printed in paper) from second page (in other words all pages except the first occur the BUG) "texts" and "images" (non-background) disappear (apparently the fault only occurs with inline elements).

See: https://bugreports.qt.io/browse/QTBUG-37240 (see the attachments to a test-case)


Bug in Qt5.0.1, Qt5.0.2 and Qt5.1.0

The first page of the print out of a QWebView with small fonts and images.

Apparently the problem only occurs with inline elements (texts and images).

Note: The error occurs in Windows XP, Windows 7, Window 7 x64, Mac OS X 10.8.3

[edit]

Source-html: http://jsfiddle.net/bdm6Y/2/

Frame content: http://jsfiddle.net/bdm6Y/2/show/

ErrorPrint

Source:

QPrinter p;
p.setPaperSize(QPrinter::A4);
p.setFullPage(true);
p.setResolution(300);
p.setOrientation(QPrinter::Portrait);

QPrintPreviewDialog preview(&p);
preview.setWindowTitle(ui->myWebView->page()->mainFrame()->title());
connect(&preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printPreview(QPrinter*)));
preview.exec();

...

void printPreview(QPrinter *printer) {
    ui->myWebView->print(printer);
}

I do not know if this is a bug or something I did wrong, what could it be?

Thanks!

[edit]

QT bug reports:

https://bugreports.qt.io/browse/QTBUG-30621

Quickie answered 31/5, 2013 at 20:52 Comment(7)
Can you please post your full HTML code somewhere?Thermotherapy
Thanks for the comment, but this is not a error in the HTML (even if the markup is bad) because in other browsers (Chrome, Firefox, etc) does not occur errors. Many sites have html markup bad (this would make the impression with "QtWebKit" impossible), but since you need an example: jsfiddle.net/bdm6Y/1 Thanks.Bookbindery
@Riateche could you help me?Bookbindery
I guess this one is related: bugreports.qt-project.org/browse/QTBUG-30937Petrel
@Petrel I also reported this yesterday: bugreports.qt-project.org/browse/QTBUG-31601 Had not existed since the same problem reported. Thanks. +1 for youBookbindery
QTBUG-30621 is closed with resolution Done in Qt 5.2.0 Alpha. Does that bugfix solve your issue?Dustproof
@troyane No, problem exists in "Qt5.2.1", they closed without analyzing law (were very reckless), see bugreports.qt-project.org/browse/QTBUG-36308Bookbindery
B
0

Problem fixed in Qt5.3

Qt 5.3 Print Support

  • New QPA class QPlatformPrintDevice to abstract platform print device hardware, new implementations for Windows, Mac and Linux.
  • QPrinterInfo provides more details on the print device hardware
  • QPrinter uses QPageSize and QPageLayout to improve page layout handling
  • QPrinter has had the behaviour of most functions standardised across all platforms (as detailed below)
  • Mac can now have each painted page with a different orientation, and can set Collate Copies and Document Name.
  • Mac and Windows now support setting Document Creator and Duplex Mode
  • Mac and Linux now support using Windows Page ID (DMPAPER values)
  • Linux now requires CUPS 1.4 (RHEL 5 no longer supported)

Code tested in Windows:

QPrinter print(QPrinter::HighResolution);
print.setPageMargins(qreal(1), qreal(1), qreal(1), qreal(1), QPrinter::Millimeter);
print.setPaperSize(QPagedPaintDevice::A4);

QPrintPreviewDialog pd(&print, mwindow, Qt::Window);
QObject::connect(&pd, SIGNAL(paintRequested(QPrinter *)), this, SLOT(preview(QPrinter *)));
if(pd.exec() == QPrintPreviewDialog::Accepted) {
    /*something*/
}

...

void MainWindow::preview(QPrinter* p) {
    mframe->print(p);//mframe is an QWebFrame
}
Bookbindery answered 31/5, 2013 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.