From: Jorge =?utf-8?b?R3V6bcOhbg==?= on 30 Nov 2006 22:04 Danny Brow <dan <at> fullmotions.com> writes: > > Anyone have a working example of the File_PDF class? > > Thanks, > Dan. > <?php require_once("File/PDF.php"); class Boleta extends File_PDF { function footer() { $this -> text(10.75, -0.5, 'Pagina '.$this -> getPageNo().' de {nb}'); } function header() { $this -> line(0, 0.5, 21.5, 0.5); } } $dim_pag = array(21.5, 14); $pdf = &File_PDF::factory(array('orientation'=>'P','unit'=>'cm', 'format'=>$dim_pag), ('Boleta')); $pdf -> open(); $pdf -> addpage(); $pdf->setFont('Arial','',7); $pdf -> image('Oax1.jpg', 1, 1, 2, 2, 'jpg'); //('archivo', X, Y, ANC, ALT, 'tipo') //Archivo de Imagen $pdf -> image('Mon1.jpg', 19.5, 1, 1.2, 2, 'jpg'); //('archivo', X, Y, ANC, ALT, 'tipo') //Archivo de Imagen $pdf -> image('Con1.jpg', 9.15, 12, 0, 0, 'jpg'); //('archivo', X, Y, ANC, ALT, 'tipo') //Archivo de Imagen $yradcp1 = 0.6; for($i=0; $i<=10;$i++){ $pdf -> circle(0.6, $yradcp1, 0.25, 'D'); //(X, y, rad, 'DF') D=borde, F=relleno, DF=relleno y borde $pdf -> circle(20.9, $yradcp1, 0.25, 'D'); $yradcp1 += 1.25; } $pdf -> line(1.2, 0, 1.2, 14); //(X1, Y1, X2, y2) $pdf -> line(20.2, 0, 20.2, 14); for($i=0; $i<=14; $i++){ $pdf -> text(0, $i, '_'.$i); } $texto = "Texto de Prueba para ejecutar el multiCell y generar varias páginas"; for($i=0; $i<=25;$i++){ $pdf -> multiCell(5, 0.3, $texto, 1, 'J', 0); } $pdf -> setDisplayMode('fullpage'); $pdf -> output('ejemplo.pdf'); //$pdf -> save('PDF/ejemplo.pdf'); //Algun directorio para guardar el archivo con permisos chmod 777 $pdf -> close(); ?>
From: "Andrew Teixeira" on 3 Dec 2006 10:31 Hello, This test works for me to display a PDF in Firefox using the Acrobat Reader plugin: require_once 'File/PDF.php'; $options = array('orientation' => 'P', 'unit' => 'pt', 'format' => 'Letter'); $pdf =& File_PDF::factory($options); $pdf->addPage(); $pdf->setFont('Times', 'B', 12); $pdf->text(10, 10, 'hello world'); $pdf->image('test.png', 30, 30); $pdf->close(); $pdf_len = strlen($pdf->getOutput); header('Cache-Control: no-cache'); header('Pragma: no-cache'); header('Content-Length: ' . $pdf_len); $pdf->output('test.pdf', true); I have been using File_PDF for a little while (and FPDF a while before that, so I have been using it a while), and the only problem I can see with your code is you called $pdf->close() after $pdf->output(). Try calling $pdf->close() after all PDF editing is done, but before $pdf->output(), even though $pdf->output() should call $pdf->close() per the documentation. Also, not sure why you put 'Boleta' in parentheses in the factory call. You may also try using the header calls in the code example above as sometimes caching can be a problem with PDF documents. Also, if you plan to use sessions, you may need to make the following function call in whatever script creates the PDF document session_cache_limiter('private'); as default cache settings of 'nocache' cause problems with displaying or saving PDF's in browsers as the PDF is not allowed to be cached (see session_cache_limiter for more details). Are you getting any sort of error messages either in the browser or in an error log? On 11/30/06, Jorge Guzmán <webmaster(a)lasdunaschahue.com.mx> wrote: > Danny Brow <dan <at> fullmotions.com> writes: > > > > > Anyone have a working example of the File_PDF class? > > > > Thanks, > > Dan. > > > > > <?php > require_once("File/PDF.php"); > > class Boleta extends File_PDF { > function footer() { > $this -> text(10.75, -0.5, 'Pagina '.$this -> getPageNo().' de > {nb}'); > } > function header() { > $this -> line(0, 0.5, 21.5, 0.5); > } > } > > $dim_pag = array(21.5, 14); > > $pdf = > &File_PDF::factory(array('orientation'=>'P','unit'=>'cm', 'format'=>$dim_pag), > ('Boleta')); > $pdf -> open(); > $pdf -> addpage(); > $pdf->setFont('Arial','',7); > $pdf -> image('Oax1.jpg', 1, 1, 2, 2, 'jpg'); //('archivo', X, Y, ANC, > ALT, 'tipo') //Archivo de Imagen > $pdf -> image('Mon1.jpg', 19.5, 1, 1.2, 2, 'jpg'); //('archivo', X, Y, ANC, > ALT, 'tipo') //Archivo de Imagen > $pdf -> image('Con1.jpg', 9.15, 12, 0, 0, 'jpg'); //('archivo', X, Y, ANC, > ALT, 'tipo') //Archivo de Imagen > > $yradcp1 = 0.6; > for($i=0; $i<=10;$i++){ > $pdf -> circle(0.6, $yradcp1, 0.25, 'D'); //(X, y, rad, 'DF') D=borde, > F=relleno, DF=relleno y borde > $pdf -> circle(20.9, $yradcp1, 0.25, 'D'); > $yradcp1 += 1.25; > } > $pdf -> line(1.2, 0, 1.2, 14); //(X1, Y1, X2, y2) > $pdf -> line(20.2, 0, 20.2, 14); > > for($i=0; $i<=14; $i++){ > $pdf -> text(0, $i, '_'.$i); > } > > > $texto = "Texto de Prueba para ejecutar el multiCell y generar varias páginas"; > > for($i=0; $i<=25;$i++){ > $pdf -> multiCell(5, 0.3, $texto, 1, 'J', 0); > } > > $pdf -> setDisplayMode('fullpage'); > $pdf -> output('ejemplo.pdf'); > //$pdf -> save('PDF/ejemplo.pdf'); //Algun directorio para guardar el archivo > con permisos chmod 777 > $pdf -> close(); > ?> > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
|
Pages: 1 Prev: PEAR::MDB2 Next: Errors are Missing in HTML_QuickForm_Renderer_Tableless 0.4.3 |