why in the generated PDF you can see only text without border
printer.setOutputFileName("C:\\Qt\\file.pdf");
printer.
setOutputFormat(QPrinter::PdfFormat);
//printer.newPage();
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);
}
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"));
}
To copy to clipboard, switch view to plain text mode
Bookmarks