i created a pdf with QtextDocument. I have a table in the pdf but the bottom of the page cuts the text instead of printing on a new page(for example my table has 300 rows, page 1 shows 1-50,page 2 shows 100-50 and so on. is there anyway to prevent the overflow.
this is the standered pdf :
1.
// QPrinter *printer=new QPrinter(QPrinter::HighResolution);
2.
// printer->setPaperSize(QPrinter::A4);
3.
// printer->setOutputFormat(QPrinter::PdfFormat);
4.
// printer->setOrientation(QPrinter::Portrait);
5.
// printer->setFullPage(true);
6.
// printer->setOutputFileName(fileName);
//and this is the table
1.
// Print Table
2.
3.
m_mainApp->m_table->SetTableWidget(table);
4.
table->setGeometry(0,0,printer.pageRect().width(),printer.pageRect().height());
5.
table->setAutoScroll(false);
6.
m_mainApp->m_table->InitTablePrint(index,printer.pageRect().width());
7.
int nbPage=m_mainApp->m_table->GetNbPrintPage(index,printer.pageRect().height());
8.
for(int page=0;page<nbPage;page++)
9.
{
10.
m_mainApp->m_table->currentIndex=-1;
11.
m_mainApp->m_table->InitTablePrint(index,printer.pageRect().width());
12.
m_mainApp->m_table->FillTablePrint(index,printer.pageRect().height(),page);
13.
painter.save();
14.
15.
painter.scale(printer.resolution()/(screenResolution*1.5f), printer.resolution()/(screenResolution*1.5f));
16.
editor->drawContents(&painter);
17.
painter.restore();
18.
printer.newPage();
19.
}
1.
// QPrinter *printer=new QPrinter(QPrinter::HighResolution);
2.
// printer->setPaperSize(QPrinter::A4);
3.
// printer->setOutputFormat(QPrinter::PdfFormat);
4.
// printer->setOrientation(QPrinter::Portrait);
5.
// printer->setFullPage(true);
6.
// printer->setOutputFileName(fileName);
//and this is the table
1.
// Print Table
2.
QTableWidget *table=new QTableWidget();
3.
m_mainApp->m_table->SetTableWidget(table);
4.
table->setGeometry(0,0,printer.pageRect().width(),printer.pageRect().height());
5.
table->setAutoScroll(false);
6.
m_mainApp->m_table->InitTablePrint(index,printer.pageRect().width());
7.
int nbPage=m_mainApp->m_table->GetNbPrintPage(index,printer.pageRect().height());
8.
for(int page=0;page<nbPage;page++)
9.
{
10.
m_mainApp->m_table->currentIndex=-1;
11.
m_mainApp->m_table->InitTablePrint(index,printer.pageRect().width());
12.
m_mainApp->m_table->FillTablePrint(index,printer.pageRect().height(),page);
13.
painter.save();
14.
QTextDocument *editor=QTableWidget2QTextDocument(table);
15.
painter.scale(printer.resolution()/(screenResolution*1.5f), printer.resolution()/(screenResolution*1.5f));
16.
editor->drawContents(&painter);
17.
painter.restore();
18.
printer.newPage();
19.
}
To copy to clipboard, switch view to plain text mode
Bookmarks