Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Wrong scaling on printing QWebView
Qt 6.11 is out! See what's new in the release blog

Wrong scaling on printing QWebView

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 448 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.
  • R Offline
    R Offline
    raginx
    wrote on last edited by
    #1

    Hello all,

    i have a QWebView loading PDF.js with an pdf file, this works fine. But when i try to print the pdf file, the page have a wrong scaling. The print have a lot of white space on the bottom and on the right.

    I discovered, that it depends on the window size. So if i reduce the window size, the white space on the print output changes.

    Here is some code:

    //Loading PDFjs with PDF
    QUrl viewer = QUrl::fromLocalFile(QFileInfo("pdfjs/web/viewer.html").absoluteFilePath());
    this->ui->webView->load(viewer.url() + "?file=../../files/pdffile.pdf");
    
    
    // Printing
    QPrinter printer;
    printer.setFullPage(true);
    
    QPrintDialog* pd = new QPrintDialog(&printer, this);
    if(pd->exec() == QDialog::Accepted) {
        this->ui->webView->print(&printer);
    }
    

    I also tried to prepare document for printing with

    this->ui->webView->page()->mainFrame()->evaluateJavaScript("window.print();");
    

    But than output is completely blank ... idk whats wrong with that :o

    What am i doing wrong?
    Thanks in advanced :)

    1 Reply Last reply
    1

    • Login

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