Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QWebView Output to PDF and Fonts
Qt 6.11 is out! See what's new in the release blog

QWebView Output to PDF and Fonts

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 746 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.
  • P Offline
    P Offline
    Pathstaken
    wrote on last edited by Pathstaken
    #1

    QT version: 4.8.6, running on Debian.
    I'm having issues with outputting an HTML document to PDF using the QPrinter.
    Code below:

    QWebView doc;
    QWebPage *page = doc.page();
    doc.setHtml(text);
    QWebSettings *settings = page->settings();
    settings->setFontFamily(QWebSettings::SansSerifFont, "URW Gothic L");
    settings->setFontSize(QWebSettings::DefaultFontSize, 12);
    QPrinter p(QPrinter::HighResolution);
    
    p.setOutputFileName("/tmp/print.pdf");
    p.setOutputFormat(QPrinter::PdfFormat);
    p.setResolution(1200);
    doc.print(&p);
    

    The HTML is valid. I even set the font inside of the HTML using CSS. (Have been styling with CSS for years).

    What I end up with is that the font is barely readable. Used to use the QTextDocument, but the CSS is limited on that, and I could not get that to do what I wanted.

    Note : the PDFs are supposed to be read in a Windows environment, but are generated in a mobile/embedded environment.

    Any help?

    Thanks,

    Travis

    Addendum:
    The fonts it ends up with are DejaVuSans-0-50 and DejaVuSans-0-75 Embedded Subset if that helps. Not even sure where those came from.

    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