void Report::printButton_clicked( const QString& html )
{
float w=533; // page width
float h=754; // page height
doc.setHtml(html);
// Set the TextDocument's page size
doc.
setPageSize( QSizeF(w, h
) );
//int pageCount=doc.pageCount();
//for ( int page=1; page<=pageCount; page++){
p.begin(&pic); // Start painting
//QRectF view(0, (page - 1) * h, w, h);
//ctx.clip = view;
// page1 and page2 only for test, i wont use the loop
//Page1
ctx.
clip = QRectF(0,
0,w,h
);
// Set the context clip to the first page
layout->draw(&p,ctx);
//Page2
//ctx.clip = QRectF(0,h,w,h); // Set the context clip to the second page
//docLayout->draw(&p,ctx);
p.end(); // End painting
//picList.append(pic);
//}
}
void Report::printButton_clicked( const QString& html )
{
QTextDocument doc;
QAbstractTextDocumentLayout::PaintContext ctx;
float w=533; // page width
float h=754; // page height
doc.setHtml(html);
// Set the TextDocument's page size
doc.setPageSize( QSizeF(w, h) );
//int pageCount=doc.pageCount();
QAbstractTextDocumentLayout *docLayout = doc.documentLayout();
QPainter p;
//for ( int page=1; page<=pageCount; page++){
QPicture pic;
p.begin(&pic); // Start painting
//QRectF view(0, (page - 1) * h, w, h);
//ctx.clip = view;
// page1 and page2 only for test, i wont use the loop
//Page1
ctx.clip = QRectF(0,0,w,h); // Set the context clip to the first page
layout->draw(&p,ctx);
//Page2
//ctx.clip = QRectF(0,h,w,h); // Set the context clip to the second page
//docLayout->draw(&p,ctx);
p.end(); // End painting
//picList.append(pic);
//}
}
To copy to clipboard, switch view to plain text mode
Bookmarks