QPrinter printer(QPrinter::HighResolution);printer.setOutputFormat(QPrinter::PdfFormat);printer.setOutputFileName("print.pdf");QTextDocument doc;.....doc->print(&printer);
QTextCursor cursor(&textDocument); QTextBlockFormat textFormat; textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysAfter); cursor.setBlockFormat(textFormat); cursor.insertHtml(html[0]); if (html.count() > 0) for (int cnt = 1; cnt < html.count(); cnt++) { cursor.insertBlock(); cursor.insertHtml(html[cnt]); } textDocument.print(&printer);