philpem / printer-driver-ptouch

P-Touch PT-series and QL-series printer driver for Linux (under CUPS)
GNU General Public License v2.0
97 stars 24 forks source link

QL-500 always prints in mirror mode #31

Closed iandall closed 1 year ago

iandall commented 1 year ago

Printing on a QL-500 is always in mirror mode. The mirror option is not set and setting it makes no difference.

This does not seem to be a hardware problem as printing from Windows 10 (using Brother proprietary driver) works.

iandall commented 1 year ago

Test pdf file: ptouch-test.pdf Job log file: ptouch.log Printed label: test label

philpem commented 1 year ago

Can you answer a few quick questions please?

Going by the log, the driver isn't being asked to mirror print data:

[2933646.838125] cupsd[1028044]: [Job 6612] rastertoptch: job options:  QL  PixelXfer=ULP  BytesPerLine=90  Align=Right  MediaType=Labels  SoftwareMirror  LabelPreamble  MinMargin=8.4  Margin=5.67  noChainPrinting  PrintDensity=0  PrintQuality=High

Note that "SoftwareMirror" only specifies that the driver should mirror print data itself (vs. asking the printer to do it). Without the "MirrorPrint" tag, it shouldn't do anything.

Further up the log:

[2933646.338836] cupsd[1028044]: [Job 6612] argv[5]="cpi=9.6 finishings=3 mirror noMirrorPrint number-up=1 pdftops-renderer=gs print-color-mode=monochrome scaling=99 job-uuid=urn:uuid:d8286a25-231d-376a-435d-6adc5252c169 job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1693567360 time-at-processing=1693567360 document-name-supplied=ptouch-test.pdf"
[2933646.338861] cupsd[1028044]: [Job 6612] argv[6]="/var/spool/cups/d06612-001"

So it seems like the mirroring is happening in foomatic-rip, in response to a request by the application to mirror the printed image.

iandall commented 1 year ago

This is:

I don't think your theory about foomatic-rip doing the mirroring holds up. I notice from the log that the "mirror" option is not known to foomatic-rip, and a check of the foomatic-rip source code shows that unknown options are just ignored. It turns out that the printers.conf file had a "Option mirror true" line and taking it out makes no difference.

Also odd, is that of I use lp -d QL-500 -o MirrorPrint <pdf file> the rastertoptch command gets the MirrorPrint argument as expected, but it makes no difference! If something else was mirroring, then getting rastertoptch to mirror should undo the other mirror.

iandall commented 1 year ago

I've narrowed it down. The mirroring is happening in pdftopdf, before it even gets to foomatic-rip. If "test.pdf" is in landscape mode, then

/usr/sbin/cupsfilter -p /etc/cups/ppd/QL-500.ppd -m application/vnd.cups-pdf test.pdf > foo.pdf

produces a rotated (portrait mode) mirrored "foo.pdf".

So it has nothing to do with "rastertoptch", but maybe it does still have something to do with the ptouch package. If I run the above command with another random PPD file I get a properly rotated, un-mirrored result. So maybe there is a strange interaction between pdftopdf and the QL-500 ppd file?

iandall commented 1 year ago

If I comment out the entire MirrorPrint block:

*%OpenUI *MirrorPrint/Mirror Print: Boolean
*%FoomaticRIPOption MirrorPrint: bool CmdLine B
*%FoomaticRIPOptionSetting MirrorPrint: " MirrorPrint "
*%OrderDependency: 110 AnySetup *MirrorPrint
*%DefaultMirrorPrint: False
*%MirrorPrint True/MirrorPrint: "%% FoomaticRIPOptionSetting: MirrorPrint=True"
*%MirrorPrint False/Normal: "%% FoomaticRIPOptionSetting: MirrorPrint=False"
*%CloseUI: *MirrorPrint

The mirroring stops. So it looks to me like "pdftopdf" sees the "MirrorPrint" option and decides to mirror regardless if it is true of false! The "pdftopdf" filter is in cups-filters-2.0~rc2-3.fc38.x86_64. Note the release candidate 2. Maybe having "pdftopdf" do mirroring is a new feature and it doesn't work. I'll try lodging a bug report with cups-filters.

iandall commented 1 year ago

It urns out it was an issue with libppd fixed for 2.0rc2.