Unsolved How to print a simple HTML table with QWebView and QPrinter without cutting off the right side?
-
Hi
Did you try using your own font ?
And set a size.
It seems the font is bigger in 4.8 -
Yes, it's bigger because the webkit versions have different default fonts. And yes I tried different font sizes etc. Sure, I can shrink the table size (e.g. via a smaller font size) to manually fit onto the page. But this is not a solution for this issue. I have dynamic generated HTML tables of different widths and the table should always fit on my A4 page (via automatic scaling by QtWebView/QtWebFrame::print). This is the normal behavior in every modern browser if you try to print a wide HTML table and it is the old behavior of Qt 4.7.4 (QtWebkit 1.x).
-
@Piotr-S.
Well i guess its a bug maybe in v2 or some of the logic changed.
Using 1.x seems best option then. -
@mrjj Unfortunately I need Qt 4.8.7. and downgrading to Qt 4.7.4 is not an option for me. So you want to tell me that Qt 4.8.7. is not able to print a simple HTML table? Maybe there is some workaround? I hope someone in this forum has a solution for me. Thank you.
-
Hi
Oh. well there might be bugs reports on
https://bugreports.qt.io
or give a day or two to see if some have work around.
We can hope :) -
Maybe a solution would be to use a
QTextDocument
. You can usesetHTML
to insert your table andprint
to aQPrinter
where yousetOutputFormat(QPrinter::PdfFormat)
. The supporte html subset ofQTextDocument
can be found here (http://doc.qt.io/qt-4.8/richtext-html-subset.html). -
@sneubert Yes I tried this solution. Unfortunately the supported HTML subset is too small for my tables.
-
@mrjj Yeah. I already tried to find a bug report but I can't find one that describes my problem.
-
@Piotr-S.
nah. Not really. I also had a fast search.
I dont have webkit for 5.7 installed so hard to test if its was later fixed but
i doubt it. -
The only option I see is to create a custom slot for
paintRequested
signal and useQPainter
withQWebFrame::render
andzoomFactor
. But this might be a nasty task. -
@mrjj said in How to print a simple HTML table with QWebView and QPrinter without cutting off the right side?:
I dont have webkit for 5.7 installed so hard to test if its was later fixed but
i doubt it.Qt 5.5 still affected
-
Hi,
@Konstantin-Tokarev QtWebKit reboot might be worth a try.
-
I would be very surprised if it works (provided Qt version is the same), but it would be better if you tried anyway :)