Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Make Table in Pdf

    Tools
    2
    3
    1279
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MrLibya last edited by

      Hello
      I was trying to make Pdf file with table , so with QPainter is kind of hard ! , so i chose to use it in HTML but didn't work

      QString html ="<html><head/><body>"
                  "<h2 style=color: #2e6c80; text-align: center;>%1 - %2 - %3</h2>"
          "<p style=text-align: center;>&nbsp;</p>"
          "<p style=text-align: center;><strong>&nbsp;</strong></p>"
          "<table style=height: 212px; width=575>"
          "<tbody>"
          "<tr>"
          "<td>"
          "<h2>1-2</h2>"
          "</td>"
          "<td>"
          "<h2>12-1</h2>"
          "</td>"
          "<td>"
          "<h2>11-12</h2>"
          "</td>"
          "<td>"
          "<h2>10-11</h2>"
          "</td>"
          "<td>"
          "<h2>9-10</h2>"
          "</td>"
          "<td>"
          "<h2>8-9</h2>"
          "</td>"
          "<td>"
          "<h2>السنة</h2>"
          "</td>"
          "<td>"
          "<h2>ايام الأسبوع</h2>"
          "</td>"
          "</tr>"
          "<tr>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>"
          "<h3>السبت</h3>"
          "</td>"
          "</tr>"
          "<tr>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "<td>&nbsp;</td>"
          "</tbody>"
          "</table>"
          "</body></html>";
          QTextDocument document;
          document.setHtml(html.arg(ConfigDialog::_university,ConfigDialog::_college,ConfigDialog::_department));
          QPrinter printer;
          printer.setPageMargins(QMarginsF(15, 15, 15, 15));
          printer.setOutputFormat(QPrinter::PdfFormat);
          printer.setPageSize(QPrinter::A4);
          printer.printRange();
          printer.setOutputFileName("table.pdf");
          document.print(&printer);
      

      so what i should chose?

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @MrLibya last edited by

        @MrLibya What exactly didn't work?
        Did you check that this HTML is interpreted correctly by QTextDocument (you can try to display it)?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply Reply Quote 0
        • M
          MrLibya @jsulm last edited by

          @jsulm no i didn't check , anyway I've used QTableWidget with span function and it dose what i want , and i will use render for the print on pdf file :)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post