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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Pull Requests

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: Mon Oct 07 15:01:28 2024 UTC