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 :


Qt Code:
  1. 1.
  2. // QPrinter *printer=new QPrinter(QPrinter::HighResolution);
  3.  
  4. 2.
  5. // printer->setPaperSize(QPrinter::A4);
  6.  
  7. 3.
  8. // printer->setOutputFormat(QPrinter::PdfFormat);
  9.  
  10. 4.
  11. // printer->setOrientation(QPrinter::Portrait);
  12.  
  13. 5.
  14. // printer->setFullPage(true);
  15.  
  16. 6.
  17. // printer->setOutputFileName(fileName);
  18.  
  19.  
  20.  
  21. //and this is the table
  22.  
  23.  
  24. 1.
  25. // Print Table
  26.  
  27. 2.
  28. QTableWidget *table=new QTableWidget();
  29.  
  30. 3.
  31. m_mainApp->m_table->SetTableWidget(table);
  32.  
  33. 4.
  34. table->setGeometry(0,0,printer.pageRect().width(),printer.pageRect().height());
  35.  
  36. 5.
  37. table->setAutoScroll(false);
  38.  
  39. 6.
  40. m_mainApp->m_table->InitTablePrint(index,printer.pageRect().width());
  41.  
  42. 7.
  43. int nbPage=m_mainApp->m_table->GetNbPrintPage(index,printer.pageRect().height());
  44.  
  45. 8.
  46. for(int page=0;page<nbPage;page++)
  47.  
  48. 9.
  49. {
  50.  
  51. 10.
  52. m_mainApp->m_table->currentIndex=-1;
  53.  
  54. 11.
  55. m_mainApp->m_table->InitTablePrint(index,printer.pageRect().width());
  56.  
  57. 12.
  58. m_mainApp->m_table->FillTablePrint(index,printer.pageRect().height(),page);
  59.  
  60. 13.
  61. painter.save();
  62.  
  63. 14.
  64. QTextDocument *editor=QTableWidget2QTextDocument(table);
  65.  
  66. 15.
  67. painter.scale(printer.resolution()/(screenResolution*1.5f), printer.resolution()/(screenResolution*1.5f));
  68.  
  69. 16.
  70. editor->drawContents(&painter);
  71.  
  72. 17.
  73. painter.restore();
  74.  
  75. 18.
  76. printer.newPage();
  77.  
  78. 19.
  79. }
To copy to clipboard, switch view to plain text mode