From 7730c04bcebbf1c9b1365bbb28e071c35d6f8dda Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Wed, 2 Nov 2011 16:12:54 +0100 Subject: [PATCH] adds the file responsiblew for PDF-Creation THis file in conjunction with PDFlib and the index.php file creates a PDF-File with a hyphenated Text. --- createPdf.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 createPdf.php diff --git a/createPdf.php b/createPdf.php new file mode 100644 index 0000000..e2d4510 --- /dev/null +++ b/createPdf.php @@ -0,0 +1,94 @@ + begin_document ( '', '' ) == 0 ) { + die("Error: " . $p -> get_errmsg () ); + } + $p -> begin_page_ext ( 1100, 600, '' ); + + $tfcreate_options = array ( 'fontname=Helvetica', 'fontsize=' . $_REQUEST ['fontsize'], 'encoding=winansi' ); + $tfcreate_options [] = 'alignment=' . $_REQUEST['alignment']; + $tfcreate_options [] = 'adjustmethod=' . $_REQUEST['adjustmethod']; + $tfcreate_options [] = 'maxspacing=' . $_REQUEST['maxspacing']; + $tfcreate_options [] = 'minspacing=' . $_REQUEST['minspacing']; + $tfcreate_options [] = 'nofitlimit=' . $_REQUEST['nofitlimit']; + $tfcreate_options [] = 'shrinklimit=' . $_REQUEST['shrinklimit']; + $tfcreate_options [] = 'spreadlimit=' . $_REQUEST['spreadlimit']; + $tfcreate_options [] = 'charspacing=' . $_REQUEST['charspacing']; + + $tffit_options = array ( 'showborder=true' ); + + $tf1 = $p -> create_textflow ( $_REQUEST ['text'], implode ( ' ', $tfcreate_options ) ); + $tf2 = $p -> create_textflow ( $_REQUEST ['text'], implode ( ' ', $tfcreate_options ) ); + $tf3 = $p -> create_textflow ( $_REQUEST ['text'], implode ( ' ', $tfcreate_options ) ); + $tf4 = $p -> create_textflow ( $_REQUEST ['text'], implode ( ' ', $tfcreate_options ) ); + $p -> fit_textflow ( $tf1, 20, 20, 400, 580,implode ( ' ', $tffit_options ) ); + $p -> fit_textflow ( $tf2, 420, 20, 720, 580,implode ( ' ', $tffit_options ) ); + $p -> fit_textflow ( $tf3, 740, 20, 960, 580,implode ( ' ', $tffit_options ) ); + $p -> fit_textflow ( $tf4, 980, 20, 1080, 580,implode ( ' ', $tffit_options ) ); + $p -> delete_textflow ( $tf1 ); + $p -> delete_textflow ( $tf2 ); + $p -> delete_textflow ( $tf3 ); + $p -> delete_textflow ( $tf4 ); + + $tf = $p -> create_textflow ( implode ( ' ', $tfcreate_options ), 'fontname=Helvetica fontsize=9 encoding=winansi' ); + $p -> fit_textflow ( $tf, 5, 5, 1095, 18,implode ( ' ', $tffit_options ) ); + $p -> delete_textflow ( $tf ); + $p -> end_page_ext ( '' ); + $p -> end_document ( '' ); + $buf = $p -> get_buffer (); + $len = strlen ( $buf ); + header("Content-type: application/pdf"); + header("Content-Length: $len"); + header("Content-Disposition: inline; filename=hello.pdf"); + print $buf; +} catch ( PDFlibException $e ) { + die("

PDFlib exception occurred

" . + "

" . $e->get_errnum() . " " . $e->get_apiname() . ": " . + $e->get_errmsg() . "

" . $e -> getFile () . ': ' . $e -> getLine () . '

'); +} +?> \ No newline at end of file