Skip to content

Commit

Permalink
Fixes & allow more than one print copy
Browse files Browse the repository at this point in the history
  • Loading branch information
GM-Script-Writer-62850 committed Sep 24, 2014
1 parent 198b3ee commit 7a8c538
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 14 deletions.
14 changes: 12 additions & 2 deletions README
Expand Up @@ -5,8 +5,8 @@ Based on Linux Scanner Server 1.2 Beta

Released under the GPL 2.0

Last Update: 9/8/2014 (Month/Day/Year)
For Version: 1.4-11_dev
Last Update: 9/22/2014 (Month/Day/Year)
For Version: 1.4-12_dev

Change Log:
https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server/wiki/Change-Log
Expand All @@ -29,6 +29,7 @@ The following packages need to be installed:
+ libpaper-utils - For detecting paper sizes
+ sed - Used in the fallback method of detecting tesseract languages
+ grep - Used in the fallback method of detecting tesseract languages
_ cups - Required if you want to use the printer service
_ php5-cli - For running php from command line
_ curl - For making url request via command line through the network (alternative to php5-cli)
_ tesseract-ocr-eng - English language file for tesseract
Expand Down Expand Up @@ -218,6 +219,15 @@ Frequently asked questions/issues:
because the selected paper size will only fit in the scanner one way
Why is the pdf download (single page) not working I keep getting a file with a error in it
The script assumes fpdf.php is located in /usr/share/php/fpdf/ this is set on line 2 of download.php
Why is it hanging up when I search for printers
It assumes all found printers are connected to the computer, lpoptions seems to hang when the printer it is looking for is not there
How do I increase the max upload size for PDFs?
You need to edit your php.ini file
for me it was located in
/etc/php5/apache2/php.ini
You will need to change the post_max_size and upload_max_filesize
For me theres were on lines 673 and 805
If post_max_size is the lower value it will limit the upload size, this value should in practive be the larger value by just a little
Internal Configuration Options:
Free Space Warning
This puts a warning on the page if you are low on disk space
Expand Down
2 changes: 1 addition & 1 deletion config.ini
Expand Up @@ -12,5 +12,5 @@ TimeZone = '' ; Time zone override (used with scan file names) List
Printer = 0 ; 0 mean printing is disabled, 1 means integrated printer, 2 means upload printer, 3 means upload/integrated printing
; No need to mess with these
NAME = "PHP Scanner Server" ; Application Name
VER = "1.4-11_dev" ; Scanner Version
VER = "1.4-12_dev" ; Scanner Version
SAE_VER = "1.4" ; Scanner Access Enabler version
3 changes: 1 addition & 2 deletions index.php
Expand Up @@ -582,9 +582,8 @@ function quit(){
$help=file_get_contents('res/scanhelp/'.$OP[$i]->{"NAME"});
// Get Source
$sources=strpos($help,'--source ');
if(is_bool($sources)){
if(is_bool($sources))
$defSource='Inactive';
}
else{
$sources=substr($help,$sources+9);
$defSource=substr($sources,strpos($sources,' [')+2);
Expand Down
20 changes: 13 additions & 7 deletions res/inc/printer.php
Expand Up @@ -28,20 +28,26 @@ function convertPHPSizeToBytes($sSize){// http://stackoverflow.com/questions/130
function getMaximumFileUploadSize(){// http://stackoverflow.com/questions/13076480/php-get-actual-maximum-upload-size
return min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
}
if( isset($_FILES['pdf']) || isset($_POST['raw']) ){
if(isset($_POST['raw'])){
if(isset($_POST['format'])){
if( $_POST['format']=='raw' && strlen($_POST['raw'])>0 ){
$file='/tmp/'.md5(time().rand()).'.txt';
SaveFile($file,$_POST['raw']);
include('res/printer.php');
unlink($file);
}
else{
if(mime_content_type($_FILES['pdf']['tmp_name'])=='application/pdf'){
else if($_POST['format']=='raw'){
Print_Message('Error','You forgot to include the text to print...','center');
}
else if( $_POST['format']=='pdf' && isset($_FILES['pdf']) ){
if(strlen($_FILES['pdf']['name'])==0){
Print_Message('Error','You forgot to include the PDF File to print...','center');
}
else if(mime_content_type($_FILES['pdf']['tmp_name'])=='application/pdf'){
$file=$_FILES['pdf']['tmp_name'];
include('res/printer.php');
}
else{
Print_Message('Error',html($_FILES['pdf']['name'].' does not look like a PDF'),$ALIGN);
Print_Message('Error',html($_FILES['pdf']['name']).' does not look like a PDF','center');
}
}
}
Expand All @@ -55,8 +61,8 @@ function getMaximumFileUploadSize(){// http://stackoverflow.com/questions/130764
<h2>Printer Configuration</h2>
<div id="p_config">
<script type="text/javascript">
var printers=<?php
$f=file_get_contents('config/printers.json');
var printers=<?php
$f=file_get_contents('config/printers.json');
echo $f===false?'\'Printers have not been configured, please <a href="index.php?page=Config&action=Search-For-Printers">search for printers</a> on the <a href="index.php?page=Config">Configure</a> page.\'':$f;
?>;
if(typeof printers=="object"){
Expand Down
16 changes: 16 additions & 0 deletions res/main.js
Expand Up @@ -411,6 +411,7 @@ function checkScanners(){
function buildPrinterOptions(json,p,P){
var printer,i,opt,val,DIV,SEL,OPT;
p.innerHTML='';

DIV=document.createElement('div');
DIV.style.display='inline-block';
DIV.innerHTML='<div class="label">Printer: </div><div class="control"></div>';
Expand All @@ -429,6 +430,21 @@ function buildPrinterOptions(json,p,P){
OPT.setAttribute('selected','selected');
SEL.appendChild(OPT);
}

DIV=document.createElement('div');
DIV.style.display='inline-block';
DIV.innerHTML='<div class="label">Quanity:</div><div class="control"></div>';
SEL=document.createElement('select');
SEL.name='quanity';
for(i=0;i<100;i++){
OPT=document.createElement('option');
OPT.value=i+1;
OPT.textContent=i+1;
SEL.appendChild(OPT);
}
DIV.childNodes[1].appendChild(SEL);
p.appendChild(DIV);

printer=P?P:SEL.value;
for(i in json[printer]){
DIV=document.createElement('div');
Expand Down
8 changes: 6 additions & 2 deletions res/printer.php
Expand Up @@ -7,11 +7,13 @@
$lpstat='lpstat -a | awk \'{print $1}\'';// command used to find printers
if(function_exists('exe')){// internal call via inc/printer.php
if(isset($file)){
$_POST['quanity']=intval($_POST['quanity']);
$q=$_POST['quanity']>0?$_POST['quanity']:1;
$o=escapeshellarg($_POST['options']);
Print_Message(
$_POST['printer'],
'Your document is being processed:<br/><pre>'.html(
exe('lp -d '.shell($_POST['printer'])." -o $o $file",true) // Print via Printer page
exe('lp -d '.shell($_POST['printer'])." -n $q -o $o $file",true) // Print via Printer page
).'</pre>',
'center'
);
Expand All @@ -21,10 +23,12 @@
}
else if(isset($Printer)){ // internal call via include from ../download.php
header('Content-type: application/json; charset=UTF-8');
$_GET['quanity']=intval($_GET['quanity']);
$q=$_GET['quanity']>0?$_GET['quanity']:1;
$o=escapeshellarg($_GET['options']);
echo json_encode((object)array(
'printer'=>$_GET['printer'],
'message'=>shell_exec('lp -d '.escapeshellarg($_GET['printer'])." -o $o $file")// This line makes it print using the integrated printer
'message'=>shell_exec('lp -d '.escapeshellarg($_GET['printer'])." -n $q -o $o $file") // This line makes it print using the integrated printer
));
}
else{
Expand Down
61 changes: 61 additions & 0 deletions res/scanhelp/Hewlett-Packard ScanJet 3400C flatbed scanner
@@ -0,0 +1,61 @@
Usage: scanimage [OPTION]...

Start image acquisition on a scanner device and write image data to
standard output.

Parameters are separated by a blank from single-character options (e.g.
-d epson) and by a "=" from multi-character options (e.g. --device-name=epson).
-d, --device-name=DEVICE use a given scanner device (e.g. hp:/dev/scanner)
--format=pnm|tiff file format of output file
-i, --icc-profile=PROFILE include this ICC profile into TIFF file
-L, --list-devices show available scanner devices
-f, --formatted-device-list=FORMAT similar to -L, but the FORMAT of the output
can be specified: %d (device name), %v (vendor),
%m (model), %t (type), %i (index number), and
%n (newline)
-b, --batch[=FORMAT] working in batch mode, FORMAT is `out%d.pnm' or
`out%d.tif' by default depending on --format
--batch-start=# page number to start naming files with
--batch-count=# how many pages to scan in batch mode
--batch-increment=# increase page number in filename by #
--batch-double increment page number by two, same as
--batch-increment=2
--batch-prompt ask for pressing a key before scanning a page
--accept-md5-only only accept authorization requests using md5
-p, --progress print progress messages
-n, --dont-scan only set options, don't actually scan
-T, --test test backend thoroughly
-A, --all-options list all available backend options
-h, --help display this help message and exit
-v, --verbose give even more status messages
-B, --buffer-size=# change input buffer size (in kB, default 32)
-V, --version print version information

Options specific to device `niash:libusb:003:004':
Geometry:
-l 0..220mm (in steps of 1) [0]
Top-left x position of scan area.
-t 0..296mm (in steps of 1) [0]
Top-left y position of scan area.
-x 0..220mm (in steps of 1) [210]
Width of scan-area.
-y 0..296mm (in steps of 1) [290]
Height of scan-area.
--resolution 75|150|300|600dpi [150]
Sets the resolution of the scanned image.
Image:
--gamma-table 0..255,... (in steps of 1)
Gamma-correction table. In color mode this option equally affects the
red, green, and blue channels simultaneously (i.e., it is an intensity
gamma table).
Scan Mode:
--mode Color|Gray|Lineart [Color]
Selects the scan mode (e.g., lineart, monochrome, or color).
Enhancement:
--threshold 0..100% (in steps of 1) [inactive]
Select minimum-brightness to get a white point

Type ``scanimage --help -d DEVICE'' to get list of all options for DEVICE.

List of available devices:
niash:libusb:003:004

0 comments on commit 7a8c538

Please sign in to comment.