Results 1 to 4 of 4

Thread: QTextDocument HTML without border

  1. #1
    Join Date
    Jan 2016
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default QTextDocument HTML without border

    why in the generated PDF you can see only text without border

    Qt Code:
    1. QPrinter printer;
    2. printer.setOutputFileName("C:\\Qt\\file.pdf");
    3. printer.setOutputFormat(QPrinter::PdfFormat);
    4.  
    5.  
    6. //printer.newPage();
    7.  
    8. doc.setHtml( " <html>\n"
    9. " <head>\n"
    10. " <title>Recepta</title>\n"
    11. " <meta charset=\"UTF-16\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
    12. " </head>\n"
    13. " <body>\n"
    14. " <table style=\"width: 400px;border: 1px solid black;border-collapse: collapse\">\n"
    15. " <tr>\n"
    16. " <td colspan=\"2\" style=\"border:1px solid black;display:\">\n"
    17. " <b>Pacjent:</b>\n"
    18. " <br>"+ name + " " + surname + "<br>" + address + "<br>" + telephone + "\n"
    19. " <br>Numer ubezpieczenia: " + insurance + "\n"
    20. " <br>\n"
    21. " </td>\n"
    22. " <tr>\n"
    23. " <td colspan=\"2\" style=\"border:1px solid black;height: 300px\">\n"
    24. " <br>\n"
    25. " </td>\n"
    26. " </tr>\n"
    27. " <tr style=\"border:1px solid black\"><td style=\"border:1px solid black\">\n"
    28. " <b>Data: </b>"+ s +"\n"
    29. " <br>\n"
    30. " </td>\n"
    31. " <td style=\"border:1px solid black\">\n"
    32. " <b>Lekarz: </b>" + doctor + "\n"
    33. " <br>Telefon: \n"
    34. " </td>\n"
    35. " </tr>\n"
    36. " </table>\n"
    37. " </body>\n"
    38. "</html>");
    39.  
    40. doc.print(&printer);
    41.  
    42. QDesktopServices::openUrl(QUrl::fromUserInput("C:\\Qt\\file.pdf"));
    43.  
    44. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextDocument HTML without border

    Have you tried showing it in a QTextBrowser to see if the problem is at printing or with the QTextDocument?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTextDocument HTML without border

    QTextBrowser - it's not work

    screen

    http://prntscr.com/9vg5e7

    I have to generate table around text

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextDocument HTML without border

    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,
    _

Similar Threads

  1. Replies: 1
    Last Post: 8th October 2015, 12:11
  2. QTextDocument Table border
    By Delphi in forum Qt Programming
    Replies: 2
    Last Post: 17th June 2013, 17:30
  3. Replies: 4
    Last Post: 13th February 2012, 19:09
  4. QTextDocument Html URL
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2008, 18:00
  5. QTextDocument Html
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2007, 13:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.