#18459 [Fbk->Csd]: Crashes When using pdf_open_image_file() with a tiff
| From: | sniper@php.net | Date: | Wed, 11 Sep 2002 16:54:56 +0000 |
| Subject: | #18459 [Fbk->Csd]: Crashes When using pdf_open_image_file() with a tiff | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-19171@lists.php.net to get a copy of this message | ||
ID: 18459
Updated by: sniper@php.net
Reported By: sramage@fatpipeinternet.com
-Status: Feedback
+Status: Closed
Bug Type: PDF related
Operating System: FreeBSD
PHP Version: 4.2.1
Previous Comments:
------------------------------------------------------------------------
[2002-07-23 15:24:17] sniper@php.net
There was some problem with PDFlib and TIFFs..
The patch to fix that doesn't seem to be available
anymore (there is 4.0.3 release already).
Please update your pdflib and try again, I can not reproduce the crash.
------------------------------------------------------------------------
[2002-07-22 22:24:02] sramage@fatpipeinternet.com
sorry last one was wrong 13 lines short as I could do =)
$pdf = pdf_new();
if (pdf_open_file($pdf,"output.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);
pdf_close($pdf);
pdf_delete($pdf);
}
------------------------------------------------------------------------
[2002-07-22 22:20:32] sramage@fatpipeinternet.com
$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);
}
------------------------------------------------------------------------
[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;
?>
------------------------------------------------------------------------
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