viernes, 9 de marzo de 2012

PHP: Generar PDF desde PHP con imagenes Libreria ROS

Site Oficial de la libreria R&OS: http://www.ros.co.nz/pdf/

El uso es muy simple lo pueden ver en http://blog.unijimpe.net/generar-pdf-con-php/

lo que quedo muy corto es la inclusion de imagenes que tambien es simple y aca muestro 3 maneras de hacerlo.

<?php
error_reporting(E_ALL);
set_time_limit(0);

include "class.ezpdf.php";

$pdf->ezImage($image="ros.jpg", $pad = 0,$width = 200,$resize = 'none',$just = 'left',$border = '');
/* This function makes it much easier to simply place an image (either jpeg or png) within the flow of
text within a documen
*/

$pdf->addImage($img="ros.jpg",$x=80,$y=0,$w=200,$h=0,$quality=75);
/* Add an image to the document, this feature needs some development. But as it stands, img must be a
handle to a GD graphics object, and one or both of w or h must be specified, if only one of them is
specified, then the other is calculated by keeping the ratio of the height and width of the image
constant.
The image will be placed with its lower left corner at (x,y), and w and h refer to page units, not pixels.
*/

$pdf->addJpegFromFile($img = 'ros.jpg',$x=199, $y= $pdf->y-100 ,$w=200,$h=0);

/* Add a JPEG image to the document, this function does not require the GD functionality, so should be
usable to more people, interestingly it also seems to
be more reliable and better quality. The syntax of the command is similar to the above 'addImage'
function, though 'img' is a string containing the file name of the jpeg image.
x,y are the position of the lower left corner of the image, and w,h are the width and height. Note that
the resolution of the image in the document is defined only by the resolution of the image that you
insert, and the size that you make it on the page. If you have an image which is 500 pixels across and
then you place it on the page so that it is 72 units across then this image will be about 500 dpi (as 72
units is about 72 points which is 1 inch)
*/


ob_end_clean(); //IMPORTANTE!!
$pdf->ezStream();
?>

No hay comentarios:

Publicar un comentario