Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Print HTML content
Forum Updated to NodeBB v4.3 + New Features

Print HTML content

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 1.1k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    cccm62
    wrote on last edited by
    #1

    Hi

    I try to print HTML content combined with inline CSS.

    • If I print QWebview directly, render is OK (i.e. CSS display:block renders correctly)
      @view->print(printer);@

    • If I print just part of doc. using QTextDocument
      @QTextDocument htmlDocument = frame->findFirstElement("#qtprint");
      htmlDocument.print(printer);@

    Correct me if I'm wrong, I think this is due to "RichText limitations":https://qt-project.org/doc/qt-4.8/richtext-html-subset.html#css-properties
    => css "display" not supported
    => How to use "QWebview rendering" just for a part of HTML?

    @<body>
    ....
    <div id="qtprint">
    <style type="text/css">
    .mystyle { display:block; height:200px; background:#800000; color:#FFF; padding:2px 5px; }
    </style>
    <span class="mystyle">Test</span>
    </div>
    ......
    </body>@

    NB: the only solution I found is to use view->print(printer); with specific print CSS file to hide everything except the DIV #qtprint
    => i.e. div { display:none; } + div#qtprint { display:block; }
    But it would be better and safer to load & print only the necessary code

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved