xTuple 4.5.0 Postbooks Client Unable to Print to Cups Printer

Written by James McDonald

August 10, 2014

Currently no fix, but a hacky work-a-round listed below: I have posted largely similar content on the xtuple.org/forum hoping they will reply with a fix.

Problem: Can print PDF to local file system but cannot print to CUPS printer

Error Message: When I start xtuple client from the command line using /opt/xTuple-4.5.0/xTupleERP/xtuple. I am getting an error echoed in the terminal when trying to print of "lp: Error - unable to access "lpr" - No such file or directory"

Fault Finding Steps: Replacing /usr/bin/lp with the following script to do some fault-finding:

#!/bin/bash

# echo command line arguments passed to /usr/bin/lp
echo "$*" > /tmp/print
# redirect stdin to a file to view contents
cat <&0 > /tmp/file

I get the following in /tmp/print

Fri Aug 8 22:19:59 EST 2014
-d HP-Officejet-Pro-8500-a910b -s lpr A4 lpr media=A4

/tmp/file (STDIN) contains a nicely formatted Adobe PostScript Document

file /tmp/file 
/tmp/file: PostScript document text conforming DSC level 1.0

From what I can tell the command line is incorrect the QPrintDialog is supposed to query cups for the correct information and then pass the correct information to the printer utility (lp) to print. Which it’s not doing.

The error “lp: Error – unable to access “lpr” – No such file or directory” if you run lp -d HP-Officejet-Pro-8500-a910b -s lpr A4 lpr media=A4 from the command line the output shows that “lpr” is being treated as a file that it’s trying to print

Another hint that there is a problem with Qt viewing the printer is that the advanced properties tab in the printer dialog is blank:

xtuple.bin print dialog Advanced Tab

xtuple.bin print dialog Advanced Tab

 

Discovered I have the same problem of a blank advanced tab as my QCAD install with the difference that QCAD prints the file. So looks like the blank advanced tab is a common problem with QT 4.8.4 and it doesn’t matter what version of cups I use (CentOS 5.56 version cups-1.4.2-52.el6_5.2.x86_64) and (Fedora 20 cups-1.7.4-3.fc20.x86_64) both don’t display a populated advanced tab.

2014-08-10-230438_453x488_scrot

This is what I am hoping to see on the Advanced tab. This is from installing assistant-qt4 (qt-assistant-4.8.6-10.fc20.x86_64) which is using Qt 4.8.6

2014-08-10-230921_454x444_scrot

 

I have tried this in both Fedora 20 and CentOS 5.8 (which have different versions of system libraries).

The only thing I haven’t been able to change is swap out my HP printer for another brand in case it’s a HP or PPD problem associated with the printer.

Discovered that the version of Qt being used for xtuple (and QCAD) was  “Qt 4.8.4 (C) 2011 Nokia Corporation and/or its subsidiary(-ies)”

The version of the Printer dialog that is working is qt-4.8.6-10.fc20.x86_64 so the issue could be that 4.8.4 has a bug.

So I have discovered the QPrinterDialog on the xTuple Client is correctly passing an Adobe PostScript document on standard in to /usr/bin/lp but it’s passing bad arguments on the command line which lp is interpretting as a file e.g. “lpr” so in order to get it working I need to tell lp that the file to print is coming via stdin using the “-” option and then properly present the arguments needed for it to work so…

A fix of sorts:

Replace the /usr/bin/lp symlink with a script that fixes the command line being incorrect

#!/bin/bash
echo $* > /tmp/lp
# the above echo put the following in /tmp/lp
# -d HP-Officejet-Pro-8500-a910b -s lpr A4 lpr media=A4
# statement to redirect stdin (which contains the file to print) to a file
# cat <&0 > /tmp/file
# contents of file is a %!PS-Adobe-1.0 PostScript document   
# this line works
# /usr/bin/lp.cups -d HP-Officejet-Pro-8500-a910b -s -o media=A4 /tmp/file
# without creating the intermediate /tmp/file file
cat <&0 | /usr/bin/lp.cups -d HP-Officejet-Pro-8500-a910b -s -o media=A4 -

A cool part of the above script is the use of <&0 to redirect STDIN to  cat which then pipes the STDIN to lp.cups

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...

Ubuntu on Hyper-v

It boils town to installing linux-azure # as root or sudo apt-get update apt-get install linux-azure...