diff --git a/code/scans.php b/code/scans.php index 36a99dd..d6f8a02 100644 --- a/code/scans.php +++ b/code/scans.php @@ -8,6 +8,8 @@ function Scan($device,$resolution,$format,$destFileBase){ global $ScanImage; global $PNMtoJPEG; global $PNMtoPNG; + global $PNMtoPS; + global $PStoPDF; $DestFile=$PreviewDir.$destFileBase; $Command=$ScanImage." -d ".$device. @@ -15,21 +17,35 @@ function Scan($device,$resolution,$format,$destFileBase){ if($format=="jpg"){ $DestFile.=".jpg"; $Command.=" | {$PNMtoJPEG} --quality=100 > ".$DestFile; + $Scan=shell_exec($Command); } if($format=="png"){ $DestFile.=".png"; $Command.=" | {$PNMtoPNG} > ".$DestFile; + $Scan=shell_exec($Command); + } + if($format=="pdf"){ + $DestFile2=$DestFile.".pnm"; + $Command.=" > {$DestFile2}"; + $Scan=shell_exec($Command); + + $DestFile.=".pdf"; + $Command="cat {$DestFile2} | {$PNMtoPS} | {$PStoPDF} - {$DestFile}"; + $Convert=shell_exec($Command); } - $Scan=shell_exec($Command); return $DestFile; } function CleanUp(){ global $PreviewDir; + $Command="rm -rf ".$PreviewDir."*.pnm"; + $Delete=shell_exec($Command); $Command="rm -rf ".$PreviewDir."*.png"; $Delete=shell_exec($Command); $Command="rm -rf ".$PreviewDir."*.jpg"; $Delete=shell_exec($Command); + $Command="rm -rf ".$PreviewDir."*.pdf"; + $Delete=shell_exec($Command); } function MoveToDest($origFile){ @@ -73,7 +89,6 @@ if(RequestParm("btnScan",false)){ $baseName="Scan-".date("Y-m-d_H_i_s"); $DestFile=Scan($Scanner,$Resolution,$Format,$baseName); CropImage($DestFile); - CropImage($DestFile); }else{ $baseName="Scan-".date("Y-m-d_H_i_s"); $DestFile=Scan($Scanner,$Resolution,$Format,$baseName); @@ -88,7 +103,7 @@ echo '