hp-scan (batch-mode from ADF) cuts off PDF-picture when scan resolution is not the lowest

Bug #449647 reported by Jakob
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned

Bug Description

When using
hp-scan --adf --mode=Lineart --res=300 --size=a4 --resize=100
i get a pdf-output, but in the PDF is only a section of the full image. When i set the scan-resolution to 75, which is the lowest everything works perfect. The higher resolution the smaller the section in the PDF-file is.
Also i can see the temporary PNG-files and they are okay, so scanning works.
So I think there is only a Problem with the pdf-converter. Can you fix it?

hp-check:
---------------
| SYSTEM INFO |
---------------

Basic system information:
Linux HP6820S 2.6.30-gentoo-r6 #5 SMP Sat Oct 10 12:06:38 CEST 2009 i686 Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz GenuineIntel GNU/Linux

Distribution:
gentoo 0.0

Checking Python version...
OK, version 2.6.2 installed

Checking PyQt 4.x version...
OK, version 4.5.4 installed.

Checking for CUPS...
Status: Scheduler wird ausgeführt
Version: 1.3.10
warning: /etc/cups/cupsd.conf file not found or not accessible.

Checking for dbus/python-dbus...
dbus daemon is running.
python-dbus version: 0.82.4

------------------------------------
| COMPILE AND RUNTIME DEPENDENCIES |
------------------------------------

note: To check for compile-time only dependencies, re-run hp-check with the -c parameter (ie, hp-check -c).
note: To check for run-time only dependencies, re-run hp-check with the -r parameter (ie, hp-check -r).

Checking for dependency: CUPS - Common Unix Printing System...
OK, found.

Checking for dependency: CUPS DDK - CUPS driver development kit...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.

Checking for dependency: CUPS devel- Common Unix Printing System development files...
OK, found.

Checking for dependency: CUPS image - CUPS image development files...
OK, found.

Checking for dependency: DBus - Message bus system...
OK, found.

Checking for dependency: gcc - GNU Project C and C++ Compiler...
OK, found.

Checking for dependency: GhostScript - PostScript and PDF language interpreter and previewer...
OK, found.

Checking for dependency: libcrypto - OpenSSL cryptographic library...
OK, found.

Checking for dependency: libjpeg - JPEG library...
OK, found.

Checking for dependency: libnetsnmp-devel - SNMP networking library development files...
error: NOT FOUND! This is a REQUIRED dependency. Please make sure that this dependency is installed before installing or running HPLIP.

Checking for dependency: libpthread - POSIX threads library...
OK, found.

Checking for dependency: libtool - Library building support services...
OK, found.

Checking for dependency: libusb - USB library...
OK, found.

Checking for dependency: make - GNU make utility to maintain groups of programs...
OK, found.

Checking for dependency: PIL - Python Imaging Library (required for commandline scanning with hp-scan)...
OK, found.

Checking for dependency: PolicyKit - Administrative policy framework...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.

Checking for dependency: PyQt 4 DBus - DBus Support for PyQt4...
OK, found.

Checking for dependency: Python DBus - Python bindings for DBus...
OK, found.

Checking for dependency: Python devel - Python development files...
OK, found.

Checking for dependency: Python libnotify - Python bindings for the libnotify Desktop notifications...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.

Checking for dependency: Python XML libraries...
OK, found.

Checking for dependency: Python 2.3 or greater - Required for fax functionality...
OK, found.

Checking for dependency: Python 2.2 or greater - Python programming language...
OK, found.

Checking for dependency: Reportlab - PDF library for Python...
OK, found.

Checking for dependency: SANE - Scanning library...
OK, found.

Checking for dependency: SANE - Scanning library development files...
OK, found.

Checking for dependency: scanimage - Shell scanning program...
OK, found.

Checking for dependency: xsane - Graphical scanner frontend for SANE...
OK, found.

----------------------
| HPLIP INSTALLATION |
----------------------

Currently installed HPLIP version...
HPLIP 3.9.8 currently installed in '/usr/share/hplip'.

Current contents of '/etc/hp/hplip.conf' file:
# hplip.conf. Generated from hplip.conf.in by configure.

[hplip]
version=3.9.8

[dirs]
home=/usr/share/hplip
run=/var/run
ppd=/usr/share/ppd/HP
ppdbase=/usr/share/ppd
doc=/usr/share/doc/hplip-3.9.8
icon=/usr/share/applications
cupsbackend=/usr/libexec/cups/backend
cupsfilter=/usr/libexec/cups/filter
drv=/usr/share/cups/drv/hp

# Following values are determined at configure time and cannot be changed.
[configure]
network-build=no
pp-build=no
gui-build=yes
scanner-build=yes
fax-build=no
dbus-build=yes
cups11-build=no
doc-build=no
shadow-build=no
hpijs-install=no
foomatic-drv-install=no
foomatic-ppd-install=no
foomatic-rip-hplip-install=no
hpcups-install=yes
cups-drv-install=no
cups-ppd-install=yes
internal-tag=3.9.8.36
restricted-build=no
ui-toolkit=qt4
qt3=no
qt4=yes
policy-kit=no
hpijs-only-build=no
lite-build=no
udev-acl-rules=yes

Current contents of '/var/lib/hp/hplip.state' file:
# hplip.state - HPLIP runtime persistent variables.

[plugin]
installed=0
eula=0

Current contents of '~/.hplip/hplip.conf' file:
[last_used]
printer_name =
working_dir = .
device_uri = hpaio:/usb/Officejet_J6400_series?serial=MY8CI4B11C056D

[commands]
scan = /usr/bin/xsane -V %SANE_URI%

[installation]
date_time = 10/12/09 18:03:12
version = 3.9.8.36

[settings]
systray_messages = 0
systray_visible = 2

[fax]
email_address =
voice_phone =

[refresh]
rate = 30
enable = false
type = 1

[polling]
enable = false
device_list =
interval = 5

--------------------------
| DISCOVERED USB DEVICES |
--------------------------

  Device URI Model
  ---------------------------------------------------- ----------------------------
  hp:/usb/Officejet_J6400_series?serial=MY8CI4B11C056D HP Officejet J6400 series

---------------------------------
| INSTALLED CUPS PRINTER QUEUES |
---------------------------------

CanonPIXMA
----------
Type: Unknown
Device URI: smb://192.168.1.3/CANONPIXMA
PPD: /etc/cups/ppd/CanonPIXMA.ppd
PPD Description: Canon iP4500 series Ver.2.80
Printer status: Drucker CanonPIXMA ist inaktiv. Aktiviert seit Mo 05 Okt 2009 17:31:30 CEST
warning: Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend to function in HPLIP.

OfficeJet6410
-------------
Type: Printer
Device URI: hp:/usb/Officejet_J6400_series?serial=MY8CI4B11C056D
PPD: /etc/cups/ppd/OfficeJet6410.ppd
PPD Description: HP Officejet j6400 Series, hpcups 3.9.8.36
Printer status: Drucker OfficeJet6410 ist inaktiv. Aktiviert seit Mo 05 Okt 2009 17:32:43 CEST
Communication status: Good

----------------------
| SANE CONFIGURATION |
----------------------

'hpaio' in '/etc/sane.d/dll.conf'...
OK, found. SANE backend 'hpaio' is properly set up.

Checking output of 'scanimage -L'...
device `hpaio:/usb/Officejet_J6400_series?serial=MY8CI4B11C056D' is a Hewlett-Packard Officejet_J6400_series all-in-one

---------------------
| PYTHON EXTENSIONS |
---------------------

Checking 'cupsext' CUPS extension...
OK, found.

Checking 'pcardext' Photocard extension...
OK, found.

Checking 'hpmudext' I/O extension...
OK, found.

Checking 'scanext' SANE scanning extension...
OK, found.

-----------------
| USB I/O SETUP |
-----------------

Checking for permissions of USB attached printers...

HP Device 0x3312 at 002:006:
    Device URI: hp:/usb/Officejet_J6400_series?serial=MY8CI4B11C056D
    Device node: /dev/bus/usb/002/006
    Mode: 0666
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/002/006
# owner: root
# group: scanner
user::rw-
group::rw-
other::rw-

---------------
| USER GROUPS |
---------------

wheel audio cdrom video games users plugdev apache ftp mrbobble scanner

-----------
| SUMMARY |
-----------

error: 5 errors and/or warnings.

Please refer to the installation instructions at:
http://hplip.sourceforge.net/install/index.html

Revision history for this message
David Keaton (dmk-dmk) wrote :

I have the same problem, and for me it does not require the use of the ADF. The following command is sufficient to reproduce it for me.

hp-scan -mlineart --size=letter

Revision history for this message
David Keaton (dmk-dmk) wrote :

Oops, I meant to include the --pdf option.

hp-scan -mlineart --size=letter --pdf

Revision history for this message
David Keaton (dmk-dmk) wrote :

Or rather, -spdf. I wish it would let me edit my comments.

hp-scan -mlineart --size=letter -spdf

Revision history for this message
David Keaton (dmk-dmk) wrote :

I think I see what's wrong with what hp-scan is doing. When I do it in two separate steps, it works.

hp-scan -mlineart --size=letter
convert -density 300 hpscan001.jpg hpscan001.pdf

But when I try to get hp-scan to do it all at once,
hp-scan -mlineart --size=letter -spdf
it shows the problem. In fact, I get the same output as if I had forgotten the "-density 300" option to convert, and then cropped the page to letter size.

So, hp-scan is probably just not passing the resolution through to the final step.

Revision history for this message
Ramon de Vries (ramondevries) wrote :

I had the same issue, the problem is in drawInlineImage function, if no width and height are given the default pdf resolution of 75 dpi is taken (1 pixel per pt).

I patched the drawInlineImage call in hp-scan (2 times) from:

                    c.drawInlineImage(image, (tlx/0.3528), ((bry_max/0.3528)-(bry/0.3528)),

                    #c.drawInlineImage(image, 0, bry/0.3528,
                        width=None,height=None)

to:
                   c.drawInlineImage(image, (tlx/0.3528), ((bry_max/0.3528)-(bry/0.3528)),
                        width=((brx-tlx)/0.3528),height=((bry-tly)/0.3528))

And it now seems to be working (better).

Revision history for this message
David Keaton (dmk-dmk) wrote :

Thanks, Ramon! Your patch fixes most of the problem, and you inspired me to take it the rest of the way. Here is my patch, which makes it work just as I expect it should.

--- scan.py- 2010-05-12 17:45:16.000000000 -0600
+++ scan.py 2010-05-23 11:21:04.976507388 -0600
@@ -959,7 +959,7 @@
             if not output:
                 output = utils.createSequencedFilename("hpscan", ".pdf")

- c = canvas.Canvas(output, (tlx_max/0.3528, bry_max/0.3528))
+ c = canvas.Canvas(output, (brx/0.3528, bry/0.3528))
             #print c

             #for p in adf_page_files:
@@ -970,10 +970,8 @@
                 #print image

                 try:
- c.drawInlineImage(image, (tlx/0.3528), ((bry_max/0.3528)-(bry/0.3528)),
-
- #c.drawInlineImage(image, 0, bry/0.3528,
- width=None,height=None)
+ c.drawInlineImage(image, (tlx/0.3528), 0,
+ width=((brx-tlx)/0.3528),height=((bry-tly)/0.3528))
                 except NameError:
                     log.error("A problem has occurred with PDF generation. This is a known bug in ReportLab. Please update your install of ReportLab to version 2.0 or greater.")
                     sys.exit(1)
@@ -1060,11 +1058,11 @@
                 bry_max = device.getOptionObj('br-y').constraint[1]

                 pdf_output = utils.createSequencedFilename("hpscan", ".pdf")
- c = canvas.Canvas(pdf_output, (tlx_max/0.3528, bry_max/0.3528))
+ c = canvas.Canvas(pdf_output, (brx/0.3528, bry/0.3528))

                 try:
- c.drawInlineImage(im, (tlx/0.3528), ((bry_max/0.3528)-(bry/0.3528)),
- width=None,height=None)
+ c.drawInlineImage(im, (tlx/0.3528), 0,
+ width=((brx-tlx)/0.3528),height=((bry-tly)/0.3528))
                 except NameError:
                     log.error("A problem has occurred with PDF generation. This is a known bug in ReportLab. Please update your install of ReportLab to version 2.0 or greater.")
                     continue

Revision history for this message
David Keaton (dmk-dmk) wrote :

Oops, my third argument to drawInlineImage should not have been zero. Here is my corrected patch.

--- scan.py- 2010-05-12 17:45:16.000000000 -0600
+++ scan.py 2010-05-23 11:38:29.567144276 -0600
@@ -959,7 +959,7 @@
             if not output:
                 output = utils.createSequencedFilename("hpscan", ".pdf")

- c = canvas.Canvas(output, (tlx_max/0.3528, bry_max/0.3528))
+ c = canvas.Canvas(output, (brx/0.3528, bry/0.3528))
             #print c

             #for p in adf_page_files:
@@ -970,10 +970,8 @@
                 #print image

                 try:
- c.drawInlineImage(image, (tlx/0.3528), ((bry_max/0.3528)-(bry/0.3528)),
-
- #c.drawInlineImage(image, 0, bry/0.3528,
- width=None,height=None)
+ c.drawInlineImage(image, (tlx/0.3528), (tly/0.3528),
+ width=((brx-tlx)/0.3528),height=((bry-tly)/0.3528))
                 except NameError:
                     log.error("A problem has occurred with PDF generation. This is a known bug in ReportLab. Please update your install of ReportLab to version 2.0 or greater.")
                     sys.exit(1)
@@ -1060,11 +1058,11 @@
                 bry_max = device.getOptionObj('br-y').constraint[1]

                 pdf_output = utils.createSequencedFilename("hpscan", ".pdf")
- c = canvas.Canvas(pdf_output, (tlx_max/0.3528, bry_max/0.3528))
+ c = canvas.Canvas(pdf_output, (brx/0.3528, bry/0.3528))

                 try:
- c.drawInlineImage(im, (tlx/0.3528), ((bry_max/0.3528)-(bry/0.3528)),
- width=None,height=None)
+ c.drawInlineImage(im, (tlx/0.3528), (tly/0.3528),
+ width=((brx-tlx)/0.3528),height=((bry-tly)/0.3528))
                 except NameError:
                     log.error("A problem has occurred with PDF generation. This is a known bug in ReportLab. Please update your install of ReportLab to version 2.0 or greater.")
                     continue

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.