Bug #18459 Updated: Crashes When using pdf_open_image_file() with a tiff
| From: | sramage at fatpipeinternet dot com | Date: | Tue, 23 Jul 2002 02:20:32 +0000 |
| Subject: | Bug #18459 Updated: Crashes When using pdf_open_image_file() with a tiff | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14848@lists.php.net to get a copy of this message | ||
ID: 18459
Updated by: sramage@fatpipeinternet.com
Reported By: sramage@fatpipeinternet.com
-Status: Feedback
+Status: Open
Bug Type: PDF related
Operating System: FreeBSD
PHP Version: 4.2.1
New Comment:
$pdf = pdf_new();
if (pdf_open_file($pdf)) {
$image=pdf_open_image_file($pdf,"tiff","test.tif","page",1);
$x=pdf_get_value($pdf,"imagewidth",$image);
$y=pdf_get_value($pdf,"imageheight",$image);
pdf_begin_page($pdf,$x,$y);
pdf_place_image($pdf,$image,0,0,1);
pdf_close_image($pdf,$image);
pdf_end_page($pdf);
pdf_save($pdf);
$data=pdf_get_buffer($pdf);
pdf_close($pdf);
pdf_delete($pdf);
$fp=fopen($output_file,"w");
fwrite($fp,$data,strlen($data));
fclose($fp);
}
Previous Comments:
------------------------------------------------------------------------
[2002-07-22 21:16:06] sniper@php.net
Please provide a SHORT script...and by short we mean under 10 lines..
------------------------------------------------------------------------
[2002-07-21 17:02:00] sramage@fatpipeinternet.com
self contained code below
here is link to a standard tiff file
http://fatpipeinternet.com/test/before1.tif
<?php
@define ("DOCUMENT_TIFF", "tiff");
function TIFFtoPDF($input_file,$output_file=false){
if(file_exists($input_file)){
if(!$output_file){
$ext=strrev(strtok(strrev($input_file),"."));
$core=strrev(strtok(""));
$output_file=$core.".pdf";
}
$pdf = pdf_new();
if (pdf_open_file($pdf)) {
pdf_set_parameter($pdf, "warning", "true");
pdf_set_info($pdf, "Creator", "Automatic");
pdf_set_info($pdf, "Author", "Automatic");
pdf_set_info($pdf, "Title", basename($input_file));
pdf_set_info($pdf, "Subject", "Generated PDF Document");
$count=1;
while($image=pdf_open_image_file($pdf,DOCUMENT_TIFF,$input_file,"page",$count)){
if($count>2){
break;
}
$x=pdf_get_value($pdf,"imagewidth",$image);
$y=pdf_get_value($pdf,"imageheight",$image);
pdf_begin_page($pdf,$x,$y);
pdf_place_image($pdf,$image,0,0,1);
pdf_close_image($pdf,$image);
pdf_end_page($pdf);
$count++;
}
pdf_save($pdf);
$data=pdf_get_buffer($pdf);
pdf_close($pdf);
pdf_delete($pdf);
$fp=fopen($output_file,"w");
fwrite($fp,$data,strlen($data));
fclose($fp);
$return=$output_file;
}else{
$return=false;
}
}else{
$return=false;
}
}
$passs_or_fail="";
if(is_array($_FILES)){
while(list($k,$file_array)=each($_FILES)){
if(file_exists($file_array["tmp"])){
if(TiffToPDF($file_array["tmp"],"tiff_to_pdf_test.pdf")){
$pass_or_fail="PASSED<iframe width=\"500\" height=\"200\"
src=\"tiff_to_pdf_test.pdf\"></iframe>";
}else{
$pass_or_fail="couldn't Convert TIFF to PDF";
}
}else{
$pass_or_fail="File didn't upload";
}
}
}
$output="$pass_or_fail<BR><form enctype=\"multipart/form-data\"
action=\"\" method=\"post\">Send this file: <input
name=\"userfile\"
type=\"file\"><input type=\"submit\" value=\"Send
File\"></form>";
echo $output;
?>
------------------------------------------------------------------------
[2002-07-21 14:04:27] derick@php.net
Then provide a short selfcontained script that reproduces the problem
so that we can try it.
Derick
------------------------------------------------------------------------
[2002-07-21 13:54:06] sramage@fatpipeinternet.com
I'm at a shared hosting facility without shell access, is there any
other way to get the needed info?
all I get access to is my HTTP access and error logs.
------------------------------------------------------------------------
[2002-07-21 13:40:52] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/18459
--
Edit this bug report at http://bugs.php.net/?id=18459&edit=1