php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12021 Problem with the data parameter in pdf_open_image()
Submitted: 2001-07-10 12:50 UTC Modified: 2001-10-08 18:47 UTC
From: fred at surleau dot com Assigned:
Status: Closed Package: PDF related
PHP Version: 4.0.6 OS: Win NT 4.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fred at surleau dot com
New email:
PHP Version: OS:

 

 [2001-07-10 12:50 UTC] fred at surleau dot com
Hi,

I use PDFLIB version 4.0.1 and PHP 4.0.6.

<?
$file = "image.jpg";
$len=filesize($file);
$fp = fopen($file, "rb");
echo $fp;
$data = fread($fp, $len);
fclose($fp);

$pdf=pdf_new();
pdf_open_file($pdf, "test.pdf");
pdf_begin_page($pdf, 595, 842);

// With pdf_open_image_file() it works !
// $pim = pdf_open_image_file($pdf, "jpeg", $file");
$pim = pdf_open_image($pdf, "jpeg", "memory", $data, $len, 300, 100, 3, 8, "" );

PDF_place_image($pdf, $pim, 100, 500, 1);
PDF_close_image($pdf, $pim);
pdf_end_page($pdf);
pdf_close($pdf);
?>

The script works with no errors, and the PDF file is created.
With pdf_open_image_file() the Jpeg file is correctly mixed in the PDF file
With pdf_open_image(), at the place in the PDF file where I should find the Jpeg data, there is garbage starting with "C:\inetpub\wwwroot" !

I need to use pdf_open_image() instead of pdf_open_image_file() because the image I want to use is not a file, it's created with the gd library, and the function pdf_open_memory_image() is not available in PHP 4.0.6 binaries for Win32.

Regards.
Fred.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-08 13:49 UTC] rjs@php.net
Hi,

I checked this with "nesrin.jpg" from the PDFlib distribution. The code:

<?
$file = "nesrin.jpg";
$len=filesize($file);
$fp = fopen($file, "rb");
echo $fp;
$data = fread($fp, $len);
fclose($fp);

$pdf=pdf_new();
pdf_open_file($pdf, "test.pdf");
pdf_begin_page($pdf, 745, 493);

$pim = pdf_open_image($pdf, "jpeg", "memory", $data, $len, 745, 493,
3, 8, "" );

PDF_place_image($pdf, $pim, 0, 0, 1);
PDF_close_image($pdf, $pim);
pdf_end_page($pdf);
pdf_close($pdf);
?>

It worked fine.

You have supply the correct parameters for widht/height/components/bpc and then it should work.

If you still have problems try to contact support@pdflib.com

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC