PDA

View Full Version : Qt 4.7 export html document to pdf: strange



giusepped
20th November 2010, 14:39
I just moved to Qt 4.7. Compilation is a charm but when I use the export to pdf document of an html content, results are different with respect to previous version.
The code (that I did not change)


medie = " <table width=680><tbody><tr bgcolor=\"lightGray\" ><td colspan=3 >"+ QObject::tr("Valori medi mensili") +"</td></tr>";
medie +="<tr><td colspan=3>";
medie +="<table width=100% border=1 cellspacing=0 cellpadding=3 ><tr><td></td>";
medie += "<td>" + QObject::tr("Energia[")+unitEnergy+"]" + "</td>";
medie += "<td>" + QObject::tr("Fattore Ombre[%]") + "</td>";
medie += "<td>" + QObject::tr("Perdite termiche[%]") + "</td>";
medie += "<td>" + QObject::tr("Altre perdite[%]") + "</td>";
medie += "<td>" + QObject::tr("Temp. medie[<sup>o</sup>]") + "</td>";
medie += "<td>" + QObject::tr("Vento medio[m/s]") + "</td>";
medie += "</tr>";

for(int i=0;i<12;i++) {
medie += "<tr>";
medie += "<td>" + MyMath::months(i+1) + "</td>";

if (Eset)
medie += "<td>" + QString("%L1").arg(E[i],0,'f',2) + "</td>";
else
medie += "<td>" + QString("%L1").arg(0) + "</td>";


medie += "<td>" + QString("%L1").arg((opt.shadows.at(i))*100,0,'f',2) + "</td>";


medie += "<td>" +QString("%L1").arg((1-
opt.thermalLosses.at(i))*100,0,'f',2) +"</td>";

medie += "<td>" + QString("%L1").arg((opt.otherLoss.at(i))*100,0,'f',2) +"</td>";


medie += "<td>" + QString("%L1").arg(opt.temperatures.at(i),0,'f',2) +"</td>";

medie += "<td>" +QString("%L1").arg(opt.wind.at(i),0,'f',2) + "</td>";

medie += "</tr>";
}
medie += "</table>";

medie += "</td></tr></tbody></table>";

And I print on a qprinter by using


m_cursor.insertHtml(medie);
m_document->drawContents(&p,printer->paperRect());

But the result is a broken table:mad:
as attached in the picture.
Why?

giusepped
21st November 2010, 22:52
Nobody interested in this bug?
Can someone reproduce the same result?
Regards

ChrisW67
21st November 2010, 23:30
What is the actual HTML that is generated? The snippet you provide above shows generation of part of a table inside (I assume) an outer table cell.

giusepped
22nd November 2010, 14:21
No. If you look carefully there are two tables, one inside the other.
If I put the output to a file and then open it with a web browser, the result is correct.
In previous version of Qt I never had such misprinting problem.

giusepped
2nd December 2010, 22:52
Nobody intrested? I also have the same problem in other similar tables...simple Chrome-readable tables.
:(

ChrisW67
2nd December 2010, 23:35
I cannot reproduce the result with either 4.6.3 or 4.7.0 on Linux. I substituted 0 for the actual figures and the month number in place of the month name, but otherwise used your code. I also used the print() method of QTextDocument with good results.