Closed kneiser closed 4 years ago
I have 3 different print methods
see line 12 of config.ini
Which method are you using?
I tested each method using the cups-pdf printer and was unable to find an issue printing a scanned file only issue i had was when choosing 'i don't care' i got a error related to this https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion and after editing like 94 of /etc/ImageMagick-6/policy.xml it works as expected (using xubuntu 20.04)
BTW your "printer options" you posted that is your scanner setting not your print settings, perhaps you are miss interrupting the UI?
3 if you look at the debug console and you see a convert command run that involves a pdf file you would get a error, you would not get error message instead of a file, in the case clicking the i do not care button you get a Error.txt file instead of a pdf
I tried again to reproduce it without success using a PNG file with a res of 5098x6598 pixels
** Suddenly tried one last thing and was able to reproduce it When you hit a print button you get a option to use the integrated print your your systems printer, when hitting cancel you get the integrated printer, this works 100% every time, however when you hit ok it loads the image on a page and open's your browsers print dialog, this is where i am able to get this problem, there is NO PDF conversion in this process, it just gives the browser a image on a page and tell the browser you want to print it
I have found 2 issues
A user with a server set with Printer set to 0 in config.ini will b confused as the only way they have to get a good print is to download a PDF and print said PDF
further testing with chome shows it will expand the image to a second page vertically, all horizontal overflow is lost tried some CSS to fix it and cups-pdf gave me a corrupt file, save to pdf in chrome works giving me a 5 page file
I have a few ideas on how to solve this
Print button only supports integrated printer
Print button opens a PDF file and we trust the user to hit the print button in the pdf
Print button opens a PDF in a iframe and we print the iframe (NOT sure if this is possible)
You reference the use of a PDF. Most times I will be using the CUPS connected printers (Cancel button) on the server. I am not always planning to print an image to PDF but just to one of the other printers. Unless you avocate that a converting image(s) to PDF is best before printing directly to a CUP connected printer on the server? On the odd occasion I would use my Linux client machine to download selected images scanned using the scanner server PDF button. Please advise.
When i refer to PDF i am not referring to the PDF made using cups-pdf, i am treating the PDF made using the cups-pdf printer as actual paper, i am referring to the backend of the scanner server UI, when you use the integrated printer the image is converted to a PDF file (in the selected format) and that pdf file is sent to the printer, be it cups-pdf, brother, hp, or xerox printer
There are 3 ways the server will make a PDF to send to the printer
The clarify my testing showed the integrated printer (hitting cancel) produces a good output every time when using the cups-pdf printer (great printer for testing as it does not waste trees and ink/toner) however when using the browser to print (hitting OK) images get cut off and do not span over to the next page as expected (firefox)
The clarify my testing showed the integrated printer (hitting cancel) produces a good output every time when using the cups-pdf printer (great printer for testing as it does not waste trees and ink/toner) however when using the browser to print (hitting OK) images get cut off and do not span over to the next page as expected (firefox) Sorry if I am causing confusion. I don't get the same results. Additionally I've not made any tweaks to any server configs. Here is the use case I used to print/test a scanned image:
Can you attach a sample scan that this happens with? Does the PDF download work?
Ok here are two zip files:
The server is running Debian 10 (Buster) current version. testscans.zip policy.xml.zip
i somehow broke my pdf printer, also noticed my /var partition is full probably related ii am blaming snap packages on this, bit i get to move a few hundred gigs around to make the partition larger... i'll test more after i fix that tomorrow
Xubuntu 20.04 unable to reproduce, you said this only happens with large files right?
cat /etc/php/7.3/apache2/php.ini | grep memory_limit
since php spawns the lp command it may be subject to the memory limit of php, mine is set to 128M
*Buster uses php 7.3, focal uses php 7.4; i never had issues with php 7.2
here are some other settings that may be different
~$ cat /etc/php/7.3/apache2/php.ini | egrep "^(memory_limit|max_execution_time|post_max_size|upload_max_filesize|html_errors|display_errors)"
max_execution_time = 30
memory_limit = 128M
display_errors = On
html_errors = On
post_max_size = 8M
upload_max_filesize = 25M
I have PrivateTmp disabled, maybe that matters? https://muras.eu/2017/12/06/apache-ubuntu-systemd-privatetmp/
I use php 7.4.
When php runs the lp command it does so from php as www-data, so i would image it has the same permission and memory restrictions
you can try running it like this
sudo -u www-data lp...
If you insert this above like 33 of printer.php it will give you a script and a pdf to try to reproduce the issue, both files will be in /tmp (requires PrivateTmp to be disabled, if you want to be able to find it)
@copy($file,"/tmp/WhyDoesItNotWork.pdf");
$S_file="/tmp/WhyDoesItNotWork.sh";
$S_file=@fopen($S_file,'w+');
@fwrite($S_file,'#!/bin/sh'."\n".'sudo -u www-data lp -d '.escapeshellarg($_GET['printer'])." -n $q -o $o /tmp/WhyDoesItNotWork.pdf");
@fclose($S_file);
I have PrivateTmp disabled. Put in the code as provided. Same results.
I even went to the command line first and issuded the sudo -u... you provided and the image printed perfectly in that case.
That code will give you file for further debugging, just to be sure nothing fishy is going on, it drops a shell script and a pdf into your server's /tmp
folder (if you do not have the files PrivateTmp is enabled)
Here are the files i get tmp.zip
The PDF is used by the script it is NOT the output of cups-pdf
[Service] Type=forking Environment=APACHE_STARTED_BY_SYSTEMD=true ExecStart=/usr/sbin/apachectl start ExecStop=/usr/sbin/apachectl stop ExecReload=/usr/sbin/apachectl graceful PrivateTmp=false Restart=on-abort
[Install] WantedBy=multi-user.target
I was not saying you had it on or off, i have had that feature annoy me more than once it really got under my skin the 1st time does it fail when you run the sh script?
I was just verifying the pretest conditions. No the script did not fail just same output issue.
if that same the same useless print but it works without the sudo -u www-data
I'd say it is a permissions issue
is www-data in the lp group?
groups www-data
if so if you put www-data in your user group does it work
kneiser@busterServer:~$ groups www-data
www-data : www-data lp kneiser
currently installing buster in a VM
Hopefully the cups and cups-pdf log files will tell me something
So how did you get it to work for your default user account
I get the same issue with www-data, root, and the user account
lp -d PDF -n 1 /tmp/WhyDoesItNotWork.pdf
I found a way to fix it, but i want to know how to detect that this is problem or how to make it not a problem, i do not like dirty patches like this
but give this a try
1.6-18a.zip [newer version in next post]
there is a option in config.ini, you will know it when you see it
for what ever reason if i run the pdf through convert and do nothing to it in theory it makes the file size explode and it works then...
Think i found a better way than using convert instead of printing a PDF we print a ps file, this takes the conversion time down from 1.248s to 0.351 seconds i think i also found out why it took forever to install debian, virtualbox was set to 1 core Take a look at this: patchResultsComparison.zip
I have changed the BusterPrintBug option from a boolean to a integer where 0 = original, 1 = pdf2ps, and 2 = convert
I reviewed the config.ini. I will try this later today.
Here are my results of printing a scanned image to either a Server network laser printer or CUPS-PDF. Did I test as expected? config.ini Settings
Printer = 1 ReplacePrinter = false BusterPrintBug = 1
Same as original issue.
Printer = 1 ReplacePrinter = false BusterPrintBug = 2
Same as original issue.
Printer = 1 ReplacePrinter = false BusterPrintBug = 0
Same as original issue.
Here is me trying to reproduce your issue: Screencast 2020-06-12 16:34:13.mp4.zip Scenarios 1 and 2 should work while 3 produces a trash bin print i used the sample image you provided for this test on a clean install of debian buster
config.ini settings using cups-pdf for output testing
Printer = 1 ReplacePrinter = false BusterPrintBug = 1
Produced a PDF file. Looks good.
Printer = 1 ReplacePrinter = false BusterPrintBug = 2
Produced a PDF file. However, as you predicted the output quality is not good.
Did not bother with Scenario 3 as we agree on the result, trash bin
So using the postscript file output provides results using cups-pdf. So what about usecases where a user wants to print a scanned image(s) directly to a CUPS network connected printer? Would you create a postscript file first then send that to the network connected printer?
BusterPrintBug = 1 converts the internal PDF to a new PDF and prints said PDF file using the lp
command
BusterPrintBug = 2 converts the internal PDF to a internal PS (post script) file then prints the PS file using the lp
command
So what about usecases where a user wants to print a scanned image(s) directly to a CUPS network connected printer?
You mean just send the image to the printer, the reason i use pdf field in the back end is PDF files print like you would expect, in my exp (until you found this quirk) they just work, now there is the 'i do not care just print it' button which converts the image file to a pdf in full auto mode no rules, no paper sizes, are you saying i should do this? lp -d PDF ../www-data/php-scanner/scans/file/Scan_0_Jun_10_2020~19-35-11.jpg
since you were able to confirm the printed file works using cups-pdf i assume it also works on a real printer?
I am assuming you are no longer able to get garbage prints with BusterPrintBug > 0 just committed quite a large update with many bug fixes, see the change log for details
Ok I just installed the new version and did some testing:
Would be nice to be able to print mulitple scanned images to a network printer from the server.
So bulk printing has a issue but bulk pdf is fine?
If that is what you are saying i can't seem to get it to happen
i did however notice something strange, if i download a pdf and use the print in firefox it works fine but if i open it in evince and print it the print is garbage, this is with BusterPrintBug = 0
also noticed that BusterPrintBug = 1
is MUCH better quality while BusterPrintBug = 2
is horrible, still better than BusterPrintBug = 0
since there is actually content on the print, my original testing showed BusterPrintBug = 1
being worse quality than BusterPrintBug = 2
the only difference in the code that runs when you use the cups-pdf driver is the name of the printer and options the printer has, this stuff is shown in the bottom of this image
The server has treats a real printer and the virtual cups-pdf exactly the same, they runs the exact same lines of code, unless you are using the pdf download there is not a single line that is different, even then both are highly integrated, though BusterPrintBug
does not apply to PDF downloads
I do consider this a bug in debian buster, i'm just adding a work around for said bug, i did check to see if this was a issue on ubuntu Groovy and was not able to get this problem
Well for bulk printing I will avoid printing multiple scanned images directly to a server network connected printer. For bulk printing I would mainly use cups-pdf and the output for muliple images is not blank like the original issue.
Just pushed a update in that will fix the quality using BusterPrintBug 2 BusterPrintBug theoretically supports values of about 9E18 but if you do something silly like that prepare to run out of system resources or hit some other software limit
I just pushed a update that may fix a secondary issue you were having basically all the printer options I was sending to lp were formatted wrong so they did nothing
I recently built up a new 64-bit Debian test server to replace an aging 32-bit machine. I've been using the PHP Scanner Server software for sometime now. While building the new machine I decided to install CUPS on the to print to 3 printers; Laser (network), Inkjet (network), and CUPS-PDF driver. I can print a test page with no problems from CUPS (v2.2.10) to the printers. However when I scan an image then print it to one of the printers only a "top-left" section of the page prints. If I print to CUPS-PDF again the same resulting output. If I go to the command-line and issue an "lp" command to print the image to one of the printers it prints great! So this seems to me that the scanning software needs to include a "fit-to-page" option issued to CUPS? I have attached a copy of the image with a red box to show the page section that prints. CUPS does not seem to have a default "fit-to-page setting" I have this same problem on my production server.