Removed spurious final blank page from PDF Writer output

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@91328 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2012-06-04 21:34:16 +00:00
parent 0502d215d0
commit 4fa6c2ceaf
4 changed files with 29 additions and 49 deletions

View File

@ -630,7 +630,9 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// table { }
$css['table']['border-collapse'] = 'collapse';
if (!$this->_isPdf) {
$css['table']['page-break-after'] = 'always';
}
// .gridlines td { }
$css['.gridlines td']['border'] = '1px dotted black';
@ -916,6 +918,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1;
$i = -1;
while($i++ < $highestColumnIndex) {
if (!$this->_isPdf) {
if (!$this->_useInlineCss) {
$html .= ' <col class="col' . $i . '">' . PHP_EOL;
} else {
@ -924,6 +927,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$html .= ' <col style="' . $style . '">' . PHP_EOL;
}
}
}
// Return
return $html;

View File

@ -67,17 +67,9 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
// Set PDF
$this->_isPdf = true;
// Build CSS
$this->buildCSS(true);
// Generate HTML
$html = '';
$html .= $this->generateHTMLHeader(false);
$html .= $this->generateSheetData();
$html .= $this->generateHTMLFooter();
// Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
@ -102,26 +94,19 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
$printPaperSize = $this->getPaperSize();
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new DOMPDF();
$pdf->set_paper(strtolower($paperSize), strtolower($orientation));
// Document info
// $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
// $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
// $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
// $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
// $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
// echo '<hr />',htmlentities($html),'<hr />';
$pdf->load_html($html);
$pdf->load_html(
$this->generateHTMLHeader(false) .
$this->generateSheetData() .
$this->generateHTMLFooter()
);
$pdf->render();
// Write to file

View File

@ -67,17 +67,9 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
// Set PDF
$this->_isPdf = true;
// Build CSS
$this->buildCSS(true);
// Generate HTML
$html = '';
$html .= $this->generateHTMLHeader(false);
$html .= $this->generateSheetData();
$html .= $this->generateHTMLFooter();
// Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
@ -91,6 +83,7 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
}
$this->setOrientation($orientation);
// Override Page Orientation
if (!is_null($this->getOrientation())) {
@ -102,12 +95,10 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
$printPaperSize = $this->getPaperSize();
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new mpdf();
$pdf->_setPageSize(strtoupper($paperSize), strtolower($orientation));
@ -119,9 +110,11 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
// echo '<hr />',htmlentities($html),'<hr />';
$pdf->WriteHTML($html);
$pdf->WriteHTML(
$this->generateHTMLHeader(false) .
$this->generateSheetData() .
$this->generateHTMLFooter()
);
// Write to file
fwrite($fileHandle, $pdf->Output('','S'));

View File

@ -68,16 +68,9 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
// Set PDF
$this->_isPdf = true;
// Build CSS
$this->buildCSS(true);
// Generate HTML
$html = '';
//$html .= $this->generateHTMLHeader(false);
$html .= $this->generateSheetData();
//$html .= $this->generateHTMLFooter();
// Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
@ -94,7 +87,8 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
// Override Page Orientation
if (!is_null($this->getOrientation())) {
$orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ?
'L' : 'P';
}
// Override Paper Size
if (!is_null($this->getPaperSize())) {
@ -123,7 +117,11 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
// Set the appropriate font
$pdf->SetFont($this->getFont());
$pdf->writeHTML($html);
$pdf->writeHTML(
$this->generateHTMLHeader(false) .
$this->generateSheetData() .
$this->generateHTMLFooter()
);
// Document info
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());