QTextDocument (html) print problems
I tried to print a html file via QTextDocument.
I use following code:
QTextDocument *doc = new QTextDocument(); doc->setHtml(htmlContent); doc->print(printer);
The result is not that what i expect.
See the attachment.
Hi. Sorry but image upload is broken. we cannot see it. Please use external site :)
now i use an external link
You should look at the doc on screen and see if same is shown.
If yes, it means that QTextDocument and you
do not agree how the HTML should be rendered :)
Have you ever seen this problem?
Nope. Looks like footer is up in data or something?
Does it also do this on screen?
no the data is in the footer/header. it just happens if the cell data has more than one row.
the last than splitts onto two pages
But it only splits to other page if page is full?
It sounds like expected action. It will not reduce font size to
make it fit :)
it splits the cell at the left ( Date ).
- change font size
- move last row to the next page
Hi, as far as I know it will only scale fonts based on DPI and not
text widths etc.
Do you have a workarround for me?
Is there a other class/option to print html files?
Sorry, no. Not really.
Only option is to tweak the html.
You can also render the widget to bitmap and control the size but that is not good quality.
We are in different time zones here on forum
so give it a day.
There might be someone that have seens this and found something for it. :)
You can test with
and maybe get other results.
I tried to compile the tool with qt 5.7.
It looks better but the last row on the page is splitted onto 2 pages.
the css-prop word-break:keep-all does not work :-(
Does look better :)
Only a subset is supported. QTextDocument is NOT a browser.
I hava a solution :-)
the problem is the css attribute "vertical-align:middle"
i remove this entry and so i have my workaround.
But i think this is a bug. From my point of view splitted rows shoud change to "vertical-align:top"
Super good work!
Well I not sure it will ever change the html on the fly.
It will simply render it as it sees it.
BUt this will be most useful to others.