bug #3164338 [pdf] Exporting database to PDF incomplete
This commit is contained in:
@@ -85,19 +85,20 @@ class PMA_PDF extends TCPDF
|
||||
function Header()
|
||||
{
|
||||
global $maxY;
|
||||
|
||||
// Check if header for this page already exists
|
||||
if (!isset($this->headerset[$this->page])) {
|
||||
$fullwidth = 0;
|
||||
foreach ($this->tablewidths as $width) {
|
||||
$fullwidth += $width;
|
||||
}
|
||||
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*2);
|
||||
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*3);
|
||||
$this->cellFontSize = $this->FontSizePt ;
|
||||
$this->SetFont(PMA_PDF_FONT, '', ($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt));
|
||||
$this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C');
|
||||
$l = ($this->lMargin);
|
||||
$this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize);
|
||||
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*1.5);
|
||||
$this->Cell(0, $this->FontSizePt, __('Database') .': ' .$this->currentDb .', ' .__('Table') .': ' .$this->currentTable, 0, 1, 'L');
|
||||
$l = ($this->lMargin);
|
||||
foreach ($this->colTitles as $col => $txt) {
|
||||
$this->SetXY($l, ($this->tMargin));
|
||||
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt);
|
||||
@@ -207,12 +208,26 @@ class PMA_PDF extends TCPDF
|
||||
$this->page = $maxpage;
|
||||
}
|
||||
|
||||
|
||||
function mysql_report($query, $attr = array())
|
||||
function setAttributes($attr = array())
|
||||
{
|
||||
foreach ($attr as $key => $val){
|
||||
$this->$key = $val ;
|
||||
}
|
||||
}
|
||||
|
||||
function setTopMargin($topMargin)
|
||||
{
|
||||
$this->tMargin = $topMargin;
|
||||
}
|
||||
|
||||
function mysql_report($query)
|
||||
{
|
||||
unset($this->tablewidths);
|
||||
unset($this->colTitles);
|
||||
unset($this->titleWidth);
|
||||
unset($this->colFits);
|
||||
unset($this->display_column);
|
||||
unset($this->colAlign);
|
||||
|
||||
/**
|
||||
* Pass 1 for column widths
|
||||
@@ -221,9 +236,6 @@ class PMA_PDF extends TCPDF
|
||||
$this->numFields = PMA_DBI_num_fields($this->results);
|
||||
$this->fields = PMA_DBI_get_fields_meta($this->results);
|
||||
|
||||
// if column widths not set
|
||||
if (!isset($this->tablewidths)){
|
||||
|
||||
// sColWidth = starting col width (an average size width)
|
||||
$availableWidth = $this->w - $this->lMargin - $this->rMargin;
|
||||
$this->sColWidth = $availableWidth / $this->numFields;
|
||||
@@ -326,13 +338,12 @@ class PMA_PDF extends TCPDF
|
||||
}
|
||||
|
||||
ksort($this->tablewidths);
|
||||
}
|
||||
|
||||
PMA_DBI_free_result($this->results);
|
||||
|
||||
// Pass 2
|
||||
|
||||
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$this->Open();
|
||||
$this->setY($this->tMargin);
|
||||
$this->AddPage();
|
||||
$this->morepagestable($this->FontSizePt);
|
||||
@@ -342,6 +353,8 @@ class PMA_PDF extends TCPDF
|
||||
|
||||
} // end of PMA_PDF class
|
||||
|
||||
$pdf = new PMA_PDF('L', 'pt', 'A3');
|
||||
|
||||
/**
|
||||
* Outputs comment
|
||||
*
|
||||
@@ -355,7 +368,7 @@ function PMA_exportComment($text)
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs export footer
|
||||
* Finalize the pdf.
|
||||
*
|
||||
* @return bool Whether it suceeded
|
||||
*
|
||||
@@ -363,11 +376,18 @@ function PMA_exportComment($text)
|
||||
*/
|
||||
function PMA_exportFooter()
|
||||
{
|
||||
global $pdf;
|
||||
|
||||
// instead of $pdf->Output():
|
||||
if (!PMA_exportOutputHandler($pdf->getPDFData())) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs export header
|
||||
* Initialize the pdf to export data.
|
||||
*
|
||||
* @return bool Whether it suceeded
|
||||
*
|
||||
@@ -375,6 +395,21 @@ function PMA_exportFooter()
|
||||
*/
|
||||
function PMA_exportHeader()
|
||||
{
|
||||
global $pdf_report_title;
|
||||
global $pdf;
|
||||
|
||||
$pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
|
||||
$pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
|
||||
$pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
|
||||
$pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
|
||||
$pdf->SetFont(PMA_PDF_FONT, '', 11.5);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->Open();
|
||||
|
||||
$attr=array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
|
||||
$pdf->setAttributes($attr);
|
||||
$pdf->setTopMargin(45);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -436,24 +471,11 @@ function PMA_exportDBCreate($db)
|
||||
*/
|
||||
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
{
|
||||
global $what;
|
||||
global $pdf_report_title;
|
||||
global $pdf;
|
||||
|
||||
$pdf = new PMA_PDF('L', 'pt', 'A3');
|
||||
|
||||
$pdf->AddFont('DejaVuSans', '', 'dejavusans.php');
|
||||
$pdf->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
|
||||
$pdf->AddFont('DejaVuSerif', '', 'dejavuserif.php');
|
||||
$pdf->AddFont('DejaVuSerif', 'B', 'dejavuserifb.php');
|
||||
$pdf->SetFont(PMA_PDF_FONT, '', 11.5);
|
||||
$pdf->AliasNbPages();
|
||||
$attr=array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
|
||||
$pdf->mysql_report($sql_query, $attr);
|
||||
|
||||
// instead of $pdf->Output():
|
||||
if (!PMA_exportOutputHandler($pdf->getPDFData())) {
|
||||
return FALSE;
|
||||
}
|
||||
$attr=array('currentDb' => $db, 'currentTable' => $table);
|
||||
$pdf->setAttributes($attr);
|
||||
$pdf->mysql_report($sql_query);
|
||||
|
||||
return TRUE;
|
||||
} // end of the 'PMA_exportData()' function
|
||||
|
Reference in New Issue
Block a user