List Info

Thread: Zend_Pdf_FileParser_Image_Jpeg ... missing?




Zend_Pdf_FileParser_Image_Jpeg ... missing?
user name
2007-11-14 11:54:09
Zend_Pdf_FileParser_Image_Jpeg does not sem to be part of my
1.0.2  
distribution. I wanted to create a PDF of images but use a
string  
rather than a filename to add the images. I decided to copy
a little  
code from Zend/Pdf/Image.php but I ran out of luck when I
only found  
that the PNG parser has been written.

This is what I wanted to do:

class PDFDocument {
     protected $pdf;

     public function __construct() {
         $this->pdf = new Zend_Pdf();
     }

     public function generatePDF($images) {

         $this->pdf->pages =
array_reverse($this->pdf->pages);

         foreach ($images as $imageName) {
             $this->pdf->page =
$this->pdf->newpage 
(Zend_Pdf_Page::SIZE_A4);
             $image = new Image($imageName);
             $imgStream =
$image->resizeWithRatio(0.4,0.4);

             $dataSource = new
Zend_Pdf_FileParserDataSource_String 
($imgStream);
             $imageParser = new
Zend_Pdf_FileParser_Image_Jpeg 
($dataSource);
             $pdfJPEG = new
Zend_Pdf_Resource_Image_Jpeg($imageParser);

             $this->pdf->page->drawImage($pdfJPEG,
10, 10, 10, 10);

             $this->pdf->pages[] =
$this->pdf->page;
         }
         $this->pdf->render();
     }
}

Am I out of luck for generating PDFs from JPEGs at this
moment in time?

-- 
Dan Field <dofllgc.org.uk>                  
Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd                                
Software Engineer
Llyfrgell Genedlaethol Cymru                   National
Library of Wales




Re: Zend_Pdf_FileParser_Image_Jpeg ... missing?
user name
2007-11-14 12:01:50
Dan,

Jpegs are supported through GD.

Use the factory method
Zend_Pdf_Image::imageWithPath('/path/to/file.jpg');

The image handling classes in Zend PDF are undergoing
transitioning and 
should not be directly used.

Kevin

Dan Field wrote:
> Zend_Pdf_FileParser_Image_Jpeg does not sem to be part
of my 1.0.2 
> distribution. I wanted to create a PDF of images but
use a string 
> rather than a filename to add the images. I decided to
copy a little 
> code from Zend/Pdf/Image.php but I ran out of luck when
I only found 
> that the PNG parser has been written.
>
> This is what I wanted to do:
>
> class PDFDocument {
>     protected $pdf;
>
>     public function __construct() {
>         $this->pdf = new Zend_Pdf();
>     }
>
>     public function generatePDF($images) {
>
>         $this->pdf->pages =
array_reverse($this->pdf->pages);
>
>         foreach ($images as $imageName) {
>             $this->pdf->page = 
> $this->pdf->newpage(Zend_Pdf_Page::SIZE_A4);
>             $image = new Image($imageName);
>             $imgStream =
$image->resizeWithRatio(0.4,0.4);
>
>             $dataSource = new 
> Zend_Pdf_FileParserDataSource_String($imgStream);
>             $imageParser = new 
> Zend_Pdf_FileParser_Image_Jpeg($dataSource);
>             $pdfJPEG = new
Zend_Pdf_Resource_Image_Jpeg($imageParser);
>
>            
$this->pdf->page->drawImage($pdfJPEG, 10, 10, 10,
10);
>
>             $this->pdf->pages[] =
$this->pdf->page;
>         }
>         $this->pdf->render();
>     }
> }
>
> Am I out of luck for generating PDFs from JPEGs at this
moment in time?
>

Re: Zend_Pdf_FileParser_Image_Jpeg ... missing?
user name
2007-11-15 03:10:37
On 14 Nov 2007, at 18:01, Kevin McArthur wrote:

> Dan,
>
> Jpegs are supported through GD.
>
> Use the factory method
Zend_Pdf_Image::imageWithPath('/path/to/ 
> file.jpg');
>
> The image handling classes in Zend PDF are undergoing
transitioning  
> and should not be directly used.

Thanks Kevin. I want to avoid creating a file during this
process. I  
have an Image class which returns me a string representation
of the  
JPEG, and would have preferred the option of handing a
string to  
Zend_Pdf_Image rather than a filename. I guess I'm out of
luck until  
the FileParser class gets finished.

-- 
Dan Field <dofllgc.org.uk>                  
Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd                                
Software Engineer
Llyfrgell Genedlaethol Cymru                   National
Library of Wales




[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )