QTextDocument (html) print problems
-
Hello,
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.https://drive.google.com/file/d/0ByPfRL92bgFrM1IxblQwNk56M28/view?usp=sharing
https://drive.google.com/file/d/0ByPfRL92bgFrVVJXbktmNFNLQVk/view?usp=sharing
-
@mschmit
Hi. Sorry but image upload is broken. we cannot see it. Please use external site :) -
thx
now i use an external link -
Super.
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?
-
@mschmit
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 -
Hi
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 ).
Expected result:
- change font size
- move last row to the next page
-
@mschmit
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? -
@mschmit
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. :) -
Oh btw
You can test with
doc.setPageSize(paperSize)
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 :-(https://drive.google.com/file/d/0ByPfRL92bgFrOUFkTS1mXzJLbHc/view?usp=sharing
-
@mschmit
Does look better :)Only a subset is supported. QTextDocument is NOT a browser.
http://doc.qt.io/qt-5/richtext-html-subset.html -
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"
https://drive.google.com/file/d/0ByPfRL92bgFrek0wbmJxME4ySXM/view?usp=sharing
-
@mschmit
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.