Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QWebView Output to PDF and Fonts
Pathstaken last edited by Pathstaken
QT version: 4.8.6, running on Debian.
I'm having issues with outputting an HTML document to PDF using the QPrinter.
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.
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.