QTextDocument allows one to create a page using HTML and output the results to a PDF file. The HTML that is allowed is listed at https://doc.qt.io/qt-5/richtext-html-subset.html. This web page states in the CSS Properties section that "border-style" is allowed, but I cannot get it to work. I want to have a solid line, but keep getting the default of ridge. Below is my code:
Qt Code:
  1. QString pdfFilePath = pdfFile; // Get the file path from the user
  2. QPdfWriter pdf_file(pdfFilePath);
  4. pdf_file.setPageSize(QPageSize(QPageSize::Letter));
  5. pdf_file.setPageMargins(QMarginsF(0.75, 0.25, 0.75, 0.25),QPageLayout::Inch);
  6. pdf_file.setPageOrientation(QPageLayout::Portrait);
  8. QPainter pdfPainter(&pdf_file);
  9. pdfPainter.setPen(Qt::black);
  10. pdfPainter.scale(10,10);
  12. QString html = "<table border = 1><tr><td>name</td><td>surname</td><td>age</td></tr></table>";
  13. doc.setDefaultStyleSheet("table {border: 1px solid black}");
  14. doc.setHtml(html);
  15. doc.drawContents(&pdfPainter);
To copy to clipboard, switch view to plain text mode 
If one plugs in a value for pdfFile (first line), you should be able to run the code.
Thank you for looking at this problem. I look forward to hearing from you.