PDA

View Full Version : Print a WebPage that isn't shown



AlexxanderX
25th September 2014, 18:35
Hello. How can I print a page that isn't showed on a window/widget?

QPainter painter(printer);
m_webView->page()->setViewportSize(m_pageToPrint->mainFrame()->contentsSize());
painter.scale(scale, scale);
m_pageToPrint->mainFrame()->render(&painter);
This is the code used( now is converted from m_webView to m_pageToPrint) to print the page from webView, which is showed, but the code for m_pageToPrint which isn't showed, only loaded with the HTML to be printed? The result of the above code is a white page in the PrinterPreviewer.
This is the code to load the html and after to call the previewer:

m_pageToPrint->mainFrame()->setHtml(finalHTML);
m_printPreviewDialog->exec();
finalHTML is a valid html code.