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. How can I print a QWebPage to a QPdfWriter?

How can I print a QWebPage to a QPdfWriter?

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 656 Views
  • 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.
  • ricokahlerR Offline
    ricokahlerR Offline
    ricokahler
    wrote on last edited by ricokahler
    #1

    Problem: I can't create multi-paged PDF documents from QWebFrame with QPdfWriter because there is no ::print() method that takes a QPagedDevice or QPdfWriter (or at least I think that's the reason)

    (context: this is for: https://github.com/ariya/phantomjs/issues/14268)

    This method is from the webpage module from PhantomJS.

    bool WebPage::renderPdf(QPdfWriter& pdfWriter)
    {
        // code removed for brevity
    
        QPainter painter(&pdfWriter);
        //m_mainFrame->render(&painter);
        QRect pageRect = pdfWriter.pageLayout().pageSize().rectPoints();
        // ===============================
        // How do I include QtPrintContext
        // ===============================
        QtPrintContext printContext(&painter, pageRect, m_mainFrame->d);
    
        for (int page = 0; page < printContext.pageCount(); page++) {
            printContext.spoolPage(page, pageRect.width());
            pdfWriter.newPage();
        }
        painter.end();
    
        return true;
    }
    

    Question: How can I #include QtPrintContext in the module above? Will this even fix the problem?

    Thanks!

    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