PDA

View Full Version : QTextDocument HTML without border



bartes19
27th January 2016, 11:29
why in the generated PDF you can see only text without border



QPrinter printer;
printer.setOutputFileName("C:\\Qt\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);


//printer.newPage();

QTextDocument doc;
doc.setHtml( " <html>\n"
" <head>\n"
" <title>Recepta</title>\n"
" <meta charset=\"UTF-16\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
" </head>\n"
" <body>\n"
" <table style=\"width: 400px;border: 1px solid black;border-collapse: collapse\">\n"
" <tr>\n"
" <td colspan=\"2\" style=\"border:1px solid black;display:\">\n"
" <b>Pacjent:</b>\n"
" <br>"+ name + " " + surname + "<br>" + address + "<br>" + telephone + "\n"
" <br>Numer ubezpieczenia: " + insurance + "\n"
" <br>\n"
" </td>\n"
" <tr>\n"
" <td colspan=\"2\" style=\"border:1px solid black;height: 300px\">\n"
" <br>\n"
" </td>\n"
" </tr>\n"
" <tr style=\"border:1px solid black\"><td style=\"border:1px solid black\">\n"
" <b>Data: </b>"+ s +"\n"
" <br>\n"
" </td>\n"
" <td style=\"border:1px solid black\">\n"
" <b>Lekarz: </b>" + doctor + "\n"
" <br>Telefon: \n"
" </td>\n"
" </tr>\n"
" </table>\n"
" </body>\n"
"</html>");

doc.print(&printer);

QDesktopServices::openUrl(QUrl::fromUserInput("C:\\Qt\\file.pdf"));

}

anda_skoa
27th January 2016, 11:57
Have you tried showing it in a QTextBrowser to see if the problem is at printing or with the QTextDocument?

Cheers,
_

bartes19
27th January 2016, 12:50
QTextBrowser - it's not work

screen

http://prntscr.com/9vg5e7

I have to generate table around text

anda_skoa
27th January 2016, 13:33
Maybe try the "border" attribute instead of specifying the border in the style.

border in style could be one of the unsupported things in Qt Rich Text

Cheers,
_