PHP: inserting an image into PDF file

User avatar
Sabina
Уже с Приветом
Posts: 5669
Joined: 13 Oct 2000 09:01
Location: East Bay, CA

PHP: inserting an image into PDF file

Post by Sabina »

I am creating PDF using only PDF extension for PHP (no PDFlib!)
For some reason code fails at
pdf_place_image(...)

Here is the code:

Code: Select all

<?php
//include JavaScript debug library
include("inc/PHP_JS_debug.php");

// create handle for new PDF document
$pdf = pdf_new();

// open a file
pdf_open_file($pdf, "image_test.pdf");

// start a new page (A4)
pdf_begin_page($pdf, 595, 842);

// open and place an image
$im = pdf_open_image_file($pdf, "gif", "sig.gif");

pdf_place_image($pdf, $im, 10, 10, 1);

pdf_close_image($pdf, $im);

// end page
pdf_end_page($pdf);

// close and save file
pdf_close($pdf);

?>


What can I be doing wrong?

Thanks,
Sabina
User avatar
Sabina
Уже с Приветом
Posts: 5669
Joined: 13 Oct 2000 09:01
Location: East Bay, CA

Re: PHP: inserting an image into PDF file

Post by Sabina »

Sabina wrote:I am creating PDF using only PDF extension for PHP (no PDFlib!)
For some reason code fails at
pdf_place_image(...)


Well, I see what is the problem now. I am actually using PDFlib syntax :(

After reviewing dozens of open source PHP PDF creation packages, I found there is no other way to produce PDFs with GIFs except PDFlib. There is only YaPs software but it's based on Ghostscript, which does not support GIFs (because CompuServe and Unisys require licening for GIF technology)

Thanks for reading anyways :)
Sabina

Return to “Вопросы и новости IT”