From b573a0d9035b2bff89e655db8163daa43223ef75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 15:31:22 +0200 Subject: [PATCH 1/4] Factor out Download method --- libraries/PDF.class.php | 10 ++++++++++ libraries/schema/Pdf_Relation_Schema.class.php | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php index 24429e39f4..b26d4d108a 100644 --- a/libraries/PDF.class.php +++ b/libraries/PDF.class.php @@ -83,4 +83,14 @@ class PMA_PDF extends TCPDF PMA_Message::error(__('Error while creating PDF:') . ' ' . $error_message)->display(); include('./libraries/footer.inc.php'); } + + /** + * Sends file as a download to user. + */ + function Download($filename) + { + $pdfData = $pdf->getPDFData(); + PMA_download_header($filename, 'application/pdf', strlen($pdfData)); + echo $pdfData; + } } diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 4f354e629d..83a7739bfb 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -903,10 +903,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema if (empty($filename)) { $filename = $pageNumber . '.pdf'; } - // instead of $pdf->Output(): - $pdfData = $pdf->getPDFData(); - PMA_download_header($filename, 'application/pdf', strlen($pdfData)); - echo $pdfData; + $pdf->Download($filename); } public function dataDictionaryDoc($alltables) From fb5483e4f288229d17e8bc288d387f03d1896177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 15:32:39 +0200 Subject: [PATCH 2/4] Do not mess with settings on download --- libraries/schema/Pdf_Relation_Schema.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 83a7739bfb..4b8eed9fd3 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -889,9 +889,6 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema { global $pdf, $db, $cfgRelation; - $pdf->SetFontSize(14); - $pdf->SetLineWidth(0.2); - $pdf->SetDisplayMode('fullpage'); // Get the name of this pdfpage to use as filename $_name_sql = 'SELECT page_descr FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' WHERE page_nr = ' . $pageNumber; From b2f0db338911e21b45f2947ec5a22dcc119c5b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 15:37:45 +0200 Subject: [PATCH 3/4] Fix download --- libraries/PDF.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php index b26d4d108a..b5629e0ee6 100644 --- a/libraries/PDF.class.php +++ b/libraries/PDF.class.php @@ -89,7 +89,7 @@ class PMA_PDF extends TCPDF */ function Download($filename) { - $pdfData = $pdf->getPDFData(); + $pdfData = $this->getPDFData(); PMA_download_header($filename, 'application/pdf', strlen($pdfData)); echo $pdfData; } From 6f22b57eb57966c7fb08e691cfcb072ca57e88af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 15:38:01 +0200 Subject: [PATCH 4/4] Fix off-by-one and invalid page references --- libraries/schema/Pdf_Relation_Schema.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 4b8eed9fd3..6e7846ab8b 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -915,7 +915,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink(); $pdf->SetX(10); // $pdf->Ln(1); - $pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i + 1) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']); + $pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']); $pdf->SetX(10); $pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']); // $pdf->Ln(1); @@ -931,7 +931,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema } $pdf->PMA_links['RT']['-'] = $pdf->AddLink(); $pdf->SetX(10); - $pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i + 1) . '}', 0, 0, 'R', 0, $pdf->PMA_links['RT']['-']); + $pdf->Cell(0, 6, __('Page number:') . ' {00}', 0, 0, 'R', 0, $pdf->PMA_links['RT']['-']); $pdf->SetX(10); $pdf->Cell(0, 6, $i . ' ' . __('Relational schema'), 0, 1, 'L', 0, $pdf->PMA_links['RT']['-']); $z = 0;