Generating PDF with QWebPahe



  • Hi,

    I'm using a QWebPage that loads the HTML content and then I'm trying to generate a PDF from it:
    @
    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName(m_fileName);
    printer.setPaperSize(QPrinter::A4);

     QPainter painter(&printer);
     painter.setRenderHint(QPainter::Antialiasing, true);
     painter.setRenderHint(QPainter::TextAntialiasing, true);
     painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
     m_page.mainFrame()->documentElement().render(&painter);
     painter.end();
    

    @

    Unfortunately the HTML content only fills up a very small part of the generated HTML page. What is the correct way to zoom the content so that it completely fills up the printing area (here in this example it's A4 without margins)?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.