Giter VIP home page Giter VIP logo

pappl's Introduction

PAPPL - Printer Application Framework

Version Apache 2.0 Build Coverity Scan Status

PAPPL is a simple C-based framework/library for developing CUPS Printer Applications, which are the recommended replacement for printer drivers. It was specifically developed to support LPrint and a future Gutenprint Printer Application but is sufficiently general purpose to support any kind of printer or driver that can be used on desktops, servers, and in embedded environments.

PAPPL supports JPEG, PNG, PWG Raster, Apple Raster, and "raw" printing to printers connected via USB and network (AppSocket/JetDirect) connections. PAPPL provides an embedded IPP Everywhere™ service that provides access to printers locally or on your whole network.

PAPPL is licensed under the Apache License Version 2.0 with an exception to allow linking against GPL2/LGPL2 software (like older versions of CUPS), so it can be used freely in any project you'd like. If you want to support the development of this framework financially, please consider sponsoring me through Github. I am also available to do consulting and/or development through my company Lakeside Robotics (https://www.lakesiderobotics.ca).

PAPPL is helping to accelerate the adoption of IPP Everywhere™ and is making it easier for developers to support other IPP-based licensing programs like AirPrint™ and Mopria®.

Requirements

PAPPL requires Microsoft® Windows® 10 or higher or a POSIX-compliant host operating system such as Linux®, macOS®, QNX®, or VxWorks®. On Windows, the provided project files require Visual Studio 2019 or higher. For POSIX hosts, a "make" utility that supports the include directive (like GNU make), a C99-compatible C compiler such as GCC or Clang, and the "pkg-config" utility are required along with the following support libraries:

  • Avahi (0.8 or later) or mDNSResponder for mDNS/DNS-SD support
  • libcups (3.0 or later) for the CUPS libraries
  • GNU TLS (3.0 or later), LibreSSL (3.0 or later), or OpenSSL (1.1 or later) for TLS support
  • JPEGLIB (8 or later) or libjpeg-turbo (2.0 or later) for JPEG image support (optional for B&W printers)
  • LIBPNG (1.6 or later) for PNG image support (optional)
  • LIBPAM for authentication support (optional)
  • LIBUSB (1.0 or later) for USB printing support (optional)
  • PAM for authentication support (optional)
  • ZLIB (1.1 or later) for compression support

Most development happens on Intel and Apple Silicon Macs, with testing on various Linux distributions, Windows 10+, and a Raspberry Pi Zero W to ensure that memory and CPU requirements remain low.

Documentation and Examples

Documentation can be found in the "doc" and "man" directories.

The OpenPrinting group has written a tutorial showing how to migrate the rastertohp driver from CUPS to a Printer Application using PAPPL, which can be used as a recipe for migrating any CUPS driver. This example is available in the hp-printer-app project and is also discussed in the PAPPL documentation.

The OpenPrinting group has also developed a PostScript printer application using PAPPL to support the many otherwise unsupported PostScript and Ghostscript-based printers.

Contributing Code and Translations

Code contributions should be submitted as pull requests on the Github site:

http://github.com/michaelrsweet/pappl/pulls

See the file "CONTRIBUTING.md" for more details.

PAPPL uses Weblate to manage the localization of the web interface and IPP attributes and values shared by all printer applications, and those likewise end up as pull requests on Github.

Legal Stuff

PAPPL is Copyright © 2019-2024 by Michael R Sweet.

This software is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software (like older versions of CUPS). See the files "LICENSE" and "NOTICE" for more information.

This software is based loosely on the "ippeveprinter.c" code from CUPS.

pappl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pappl's Issues

USB Printer Gadget support with configfs

WebIF: Add "print test page" functionality

Add a test page button to print a test page using the current printing defaults. The test page needs to:

  • Show the printer name, location, contact, etc.
  • Show the current "firmware" versions
  • For color printers, show a variety of color test patches (CMYK for sure, plus a variety of other color patches)
  • For monochrome printers, show a variety of grayscale test patches
  • Scale all of the above to fit on a single page

Finish documentation

Need to finish up the documentation now that the basic reference material is completed.

  • pappl.3 (overview/roadmap) man page
  • pappl-client.3 man page
  • pappl-device.3 man page
  • pappl-job.3 man page
  • pappl-log.3 man page
  • pappl-mainloop.3 man page
  • pappl-printer.3 man page
  • pappl-system.3 man page
  • More overview documentation ("hello, world!" program, etc.)
  • Main loop/system/logging documentation
  • Device documentation
  • Printer/driver documentation
  • Web interface/customization documentation

Feature request: Add support for hooks

Add support for hooks, similar to how tea4cups does it. It would be nice if there was a kind of generic system, like tea4cups, where we could write scripts to execute before or after the job is processed, so that lprint doesn't really need much code to handle specific use cases, but with generic hook functionality we could just write scripts to handle the specific cases with short scripts. We personally just use posthooks in tea4cups currently but tea4cups also supports prehooks and I imagine some users would have need of those.

When printing colored PNG image in gray the image does not get correctly converted

Describe the bug
When printing JPEG or PNG images with PAPPL's built-in image filters the images being color but printing being done in gray (monochrome printer or user request), the images are supposed to be converted when loading with libjpeg or libpng. This is doe correctly for JPEG images bug not for PNG. The patch below fixes this:

--- a/pappl/job-filter.c
+++ b/pappl/job-filter.c
@@ -535,7 +556,7 @@ _papplJobFilterPNG(
   // Prepare options...
   options = papplJobCreatePrintOptions(job, 1, (png.format & PNG_FORMAT_FLAG_CO
LOR) != 0);
 
-  if (png.format & PNG_FORMAT_FLAG_COLOR)
+  if (options->header.cupsNumColors > 1)
   {
     png.format = PNG_FORMAT_RGB;
     png_bpp    = 3;

Without the patch the function papplJobFilterImage() receives the 3-byte color pixels and only copies the first of the three bytes into the destination image, meaning that only the red components of the original image are used. On most photos one sees only a slight difference, but on drawings for example important parts can miss in the printout.

To Reproduce
Print PNG images with a PAPPL-based Printer Application, preferably a drawing with pure red, grren, and blue graphical elements.

System Information:

  • As usual, Ubuntu 20.10 with current GIT snapshots of ps-printer-app and PAPPL, also my fixes for my previously reported issues.

Options missing in auto-generated CUPS PPD for queue pointing to PAPPL's emulated inkjet printer

I have testpappl running and created a driverless CUPS queue for the emulated inkjet printer, but the generated PPD file seems to miss some options:

till@till-x1yoga:~/ubuntu/cups-pk-helper/focal/cups-pk-helper-0.2.6$ lpadmin -p pappl-test-e -E -v ipp://till-x1yoga.local:8000/ipp/print/Inkjet%20Printer -m everywhere
till@till-x1yoga:~/ubuntu/cups-pk-helper/focal/cups-pk-helper-0.2.6$ lpoptions -p pappl-test-e -l
PageSize/Media Size: 3x5 4x6 5x7 A4 A5 A6 Env10 EnvDL Custom.WIDTHxHEIGHT
InputSlot/Media Source: *Main Alternate Manual ByPassTray
MediaType/Media Type: *Stationery StationeryLetterhead Labels Photographic PhotographicGlossy PhotographicMatte Transparency
ColorModel/Output Mode: *Gray DeviceGray
cupsPrintQuality/cupsPrintQuality: Draft *Normal High
till@till-x1yoga:~/ubuntu/cups-pk-helper/focal/cups-pk-helper-0.2.6$ 

I get several paper sizes but neither Letter nor Legal, and as color modes I get only two grayscale modes whereas the emulated printer is actually color, according to the line

URF = V1.4,W8,SRGB8,DEVW8,PQ3-4-5,IS1-2-4-19,MT1-6-5-11-8-2,RS300-600

in its TXT record.

Jobs: "job-retain-until" attribute support

Would be really nice to add (optional) persistence for jobs. Specifically:

  • Load/save job history
  • Load/save pending (and retained) job files
  • Support for job-retain-until/-time/-interval Job Template and associate Printer attributes

Example: Add porting example for CUPS generic PCL driver to PAPPL

One of the goals for 1.0 is to provide an example printer application for the CUPS rastertohp filter and corresponding PPD files (laserjet.ppd, deskjet.ppd, and generpcl.ppd). This example should include:

  • A new PAPPL-based PCL driver
  • Code to load and save the configuration (call existing APIs)
  • Command-line and web-based configuration (web-based UI is mostly done already)
  • Snapcraft packaging template
  • systemd service file/support

WebIF: Separate header links from papplSystemAddResourceCallback API

Right now you specify a label string to papplSystemAddResourceCallback to include the resource as a link in the top header. This doesn't allow for aliasing or linking to static files.

Remove the label string and secure link stuff from the resources and instead add a way to add links instead, e.g.:

void papplSystemAddLink(pappl_system_t *system, const char *label, const char *path, bool secure);

The links should be sorted by name (label) instead of by path.

Allow building driver list and registering it in system_cb, so that list build can get logged

Is your feature request related to a problem? Please describe.
I am creating a PostScript Printer Application which should support all PostScript printers which were supported in the Linux distributions. This means that it will contain the 1000s of manufacturer-supplied PostScript PPD files ("foomatic-db" package), each one being a driver in PAPPL terms. So a list of 1000s of drivers has to be built, where easily errors can happen. Therefore I want the Printer Application to start logging before the building of the driver list starts and to start logging I have to call papplMainloop(). I call it without driver list (0 drivers, no callback) and call papplSystemSetDrivers() from within the system_cb. Problem is that papplMainloop() calls the system_cb in the beginning and afterwards it calls papplSystemSetDrivers() with the empty driver list it got supplied. It should omit the papplSystemSetDrivers() call with an empty/invalid driver list, this way one can "manually" call papplSystemSetDrivers() somewhere else, like for example in system_cb.

Describe the solution you'd like
The following patch solves the problem. Driver registration (papplSystemSetDrivers()) is only called if the papplMainloop() call actually specifies a driver list and a driver callback. If omitting these, one can register the drivers later and so build the driver list with the system available and so the possibility to log the list building process. Pre-defining the driverlist before starting the main loop and specifying the driver list and callback in the papplMainloop() is still possible.

--- a/pappl/mainloop-subcommands.c
+++ b/pappl/mainloop-subcommands.c
@@ -632,7 +632,8 @@ _papplMainloopRunServer(
     papplSystemSetFooterHTML(system, footer_html);
 
   // Set the driver info...
-  papplSystemSetDrivers(system, num_drivers, drivers, driver_cb, data);
+  if (num_drivers && drivers && driver_cb)
+    papplSystemSetDrivers(system, num_drivers, drivers, driver_cb, data);
 
   // Listen for connections...
   papplSystemAddListeners(system, _papplMainloopGetServerPath(base_name, sockna

Support streaming of raster content

Currently Apple/PWG Raster print files are saved to disk before processing. This is OK for small page data like labels but is not ideal for things like Gutenprint where there could be gigabytes of raster data.

Media trays and option defaults broken in web interface

Describe the bug
I am developing the PostScript Printer Application and some days ago it was correctly working, in terms of adding a printer, selecting the driver (= model) and then you could set media sizes and types, and also borderless (this made me report issue #50) for the printer's trays (my HP OfficeJet Pro 8730 showed two trays) and you also could set option default like duples or print quality, and actually print in the end, with the settings obeyed by the printer.
Now, with the current PAPPL no trays show any more, and also some options in the "Printing Defaults" are missing. The problem seems to be some changes in PAPPL, as I did not do any changes in populating the driver data structure, also the PPD file from which I take the info for populating the driver data was always the same.
Restarting the Printer Application always shows the same result, the trays and options missing.
Below is debug log output of the starting of the Printer Application with the printer already added, beginning from loading the state file (skipping the building of the driver list from ~4000 PPD files). It shows that the printer entry loads its (correct) PPD file, and after that it seems that PAPPL verifies the driver data as populated by the ps_callback() function (the driver callback) and finds some problems which not actually are problems:

D [2020-10-30T23:10:44.112Z] Using PPD /snap/ps-printer-app/current/usr/share/ppd//hplip-ps-ppds.tar.gz:./hp-officejet_pro_8730-ps.ppd: HP OfficeJet Pro 8730 Postscript (recommended)
D [2020-10-30T23:10:44.112Z] [Printer test] identify-actions-default=0x0004
D [2020-10-30T23:10:44.112Z] [Printer test] media-default=na_letter_8.5x11in
D [2020-10-30T23:10:44.112Z] [Printer test] orientation-requested-default=7(none)
D [2020-10-30T23:10:44.112Z] [Printer test] print-color-mode-default=auto(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] print-content-default=auto(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] print-quality-default=4(normal)
D [2020-10-30T23:10:44.112Z] [Printer test] print-scaling-default=auto(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] printer-resolution-default=600x600dpi
D [2020-10-30T23:10:44.112Z] [Printer test] sides-default=one-sided(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] Driver uses extension data (0x5593c4d951e0) and no delete function.
F [2020-10-30T23:10:44.112Z] [Printer test] Driver does not provide required raster printing callbacks.
W [2020-10-30T23:10:44.112Z] [Printer test] Driver does not support a self-test page.
D [2020-10-30T23:10:44.112Z] [Printer test] Driver reports ppm 24.
D [2020-10-30T23:10:44.112Z] [Printer test] Driver reports ppm_color 24.
W [2020-10-30T23:10:44.112Z] [Printer test] Driver does not provide printer icons, using defaults.

First one sees that the default settings got correctly extracted from the PPD file (by ps_callbck()), then it says "Driver does not provide required raster printing callbacks", but these are not actually needed as this is a non-Raster driver, the output is PostScript. Is there any mechanism of the tests being considered failed and so the driver data not being held by the system and made available in the web interface?
The state file content is the following:

DNSSDName PS Printer App (4187D4)
Contact
DefaultPrinterID 1
NextPrinterID 7
UUID urn:uuid:d9bfb18e-69d9-37d8-5de6-c65f4f4187d4
<Printer did="MFG:HP;MDL:HP OfficeJet Pro 8730;CMD:PCL5c,PCLXL,POSTSCRIPT,NATIVEOFFICE" driver="hp--officejet-pro-8730--en" id="6" name="test" uri="usb://HP/HP%20OfficeJet%20Pro%208730?serial=CN783F60W1">
Contact
MaxActiveJobs 0
MaxCompletedJobs 100
NextJobId 1
ImpressionsCompleted 0
media-col-default
</Printer>

The printer entry is there, the driver name "hp--officejet-pro-8730--en" is derived from the PPD file, a naming scheme robust agains new PPD files being added to the Snap. One sees that there are no default option settings or media selections in the file.

To Reproduce
Download the source code of the PostScript Printer Application, build the Snap (it takes automatically care of using the current GIT snapshots of PAPPL and cups-filters), and install it. Connect a printer to your system or to the network. Then run

ps-printer-app -o log-level=debug server &

Add a printer via the "Add Printer" page of the web interface, simply select the "Generic PostScript Printer" as driver if your printer is not in the list. Click the "Media" or "Printing Defaults" button and you will see screens like shown in the screenshots below. Now media trays to select paper sizes for, missing options.

Expected behavior
As before, the trays and options should show.

Screenshots
Media page: Nothing is displayed, before two trays were shown (otherwise I had not been able to report issue #50)
Screenshot from 2020-10-31 00-19-54

Option defaults page: No media selectable, double-sided option missing
Screenshot from 2020-10-31 00-20-00

System Information:

  • Ubuntu, Focal Fossa 20.04 to build Snaps, problem occurs on both 20.04 and 20.10.
  • PAPPL, cups-filters, and ps-printer-app are current GIT snapshots.

Additional context
Add any other context about the problem here.

I [2020-10-30T23:10:43.868Z] Loading system state from '/tmp/ps_printer_app.state'.
D [2020-10-30T23:10:43.868Z] Registering DNS-SD name 'PS Printer App (4187D4)' on 'till-x1yoga.local'
I [2020-10-30T23:10:43.870Z] Printer 'test' at resource path '/ipp/print/test'.
D [2020-10-30T23:10:44.112Z] Using PPD /snap/ps-printer-app/current/usr/share/ppd//hplip-ps-ppds.tar.gz:./hp-officejet_pro_8730-ps.ppd: HP OfficeJet Pro 8730 Postscript (recommended)
D [2020-10-30T23:10:44.112Z] [Printer test] identify-actions-default=0x0004
D [2020-10-30T23:10:44.112Z] [Printer test] media-default=na_letter_8.5x11in
D [2020-10-30T23:10:44.112Z] [Printer test] orientation-requested-default=7(none)
D [2020-10-30T23:10:44.112Z] [Printer test] print-color-mode-default=auto(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] print-content-default=auto(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] print-quality-default=4(normal)
D [2020-10-30T23:10:44.112Z] [Printer test] print-scaling-default=auto(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] printer-resolution-default=600x600dpi
D [2020-10-30T23:10:44.112Z] [Printer test] sides-default=one-sided(0x0001)
D [2020-10-30T23:10:44.112Z] [Printer test] Driver uses extension data (0x5593c4d951e0) and no delete function.
F [2020-10-30T23:10:44.112Z] [Printer test] Driver does not provide required raster printing callbacks.
W [2020-10-30T23:10:44.112Z] [Printer test] Driver does not support a self-test page.
D [2020-10-30T23:10:44.112Z] [Printer test] Driver reports ppm 24.
D [2020-10-30T23:10:44.112Z] [Printer test] Driver reports ppm_color 24.
W [2020-10-30T23:10:44.112Z] [Printer test] Driver does not provide printer icons, using defaults.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/icon-sm.png'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/icon-md.png'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/icon-lg.png'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/cancel'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/cancelall'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/delete'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/config'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/jobs'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/media'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/test/printing'.
I [2020-10-30T23:10:44.112Z] Listening for connections on '/tmp/ps-printer-app1000.sock'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/favicon.png'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/navicon.png'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/style.css'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/addprinter'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/config'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/network'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/security'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/tls-install-crt'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/tls-new-crt'.
D [2020-10-30T23:10:44.112Z] Adding resource for '/tls-new-csr'.
I [2020-10-30T23:10:44.112Z] Starting system.
D [2020-10-30T23:10:45.114Z] Registering DNS-SD name 'PS Printer App (4187D4)' on 'till-x1yoga.local'
I [2020-10-30T23:10:45.119Z] Saving system state to '/tmp/ps_printer_app.state'.
I [2020-10-30T23:11:23.843Z] [Client 1] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.843Z] [Client 2] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.843Z] [Client 1] Starting HTTPS session.
I [2020-10-30T23:11:23.843Z] [Client 2] Starting HTTPS session.
E [2020-10-30T23:11:23.846Z] [Client 2] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:23.846Z] [Client 2] Closing connection from 'localhost'.
E [2020-10-30T23:11:23.847Z] [Client 1] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:23.847Z] [Client 1] Closing connection from 'localhost'.
I [2020-10-30T23:11:23.860Z] [Client 3] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.860Z] [Client 3] Starting HTTPS session.
E [2020-10-30T23:11:23.863Z] [Client 3] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:23.863Z] [Client 3] Closing connection from 'localhost'.
I [2020-10-30T23:11:23.864Z] [Client 4] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.864Z] [Client 4] Starting HTTPS session.
I [2020-10-30T23:11:23.867Z] [Client 4] Connection now encrypted.
I [2020-10-30T23:11:23.868Z] [Client 4] GET https://localhost:8000/ HTTP/1.1
I [2020-10-30T23:11:23.868Z] [Client 4] OK text/html 0
I [2020-10-30T23:11:23.868Z] [Client 4] Closing connection from 'localhost'.
I [2020-10-30T23:11:23.913Z] [Client 5] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.914Z] [Client 5] Starting HTTPS session.
E [2020-10-30T23:11:23.917Z] [Client 5] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:23.917Z] [Client 5] Closing connection from 'localhost'.
I [2020-10-30T23:11:23.920Z] [Client 6] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.921Z] [Client 7] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.921Z] [Client 8] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.922Z] [Client 6] Starting HTTPS session.
I [2020-10-30T23:11:23.922Z] [Client 7] Starting HTTPS session.
I [2020-10-30T23:11:23.922Z] [Client 8] Starting HTTPS session.
E [2020-10-30T23:11:23.924Z] [Client 6] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:23.924Z] [Client 6] Closing connection from 'localhost'.
I [2020-10-30T23:11:23.925Z] [Client 9] Accepted connection from 'localhost'.
E [2020-10-30T23:11:23.925Z] [Client 7] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:23.925Z] [Client 7] Closing connection from 'localhost'.
I [2020-10-30T23:11:23.926Z] [Client 9] Starting HTTPS session.
I [2020-10-30T23:11:23.927Z] [Client 10] Accepted connection from 'localhost'.
I [2020-10-30T23:11:23.927Z] [Client 10] Starting HTTPS session.
I [2020-10-30T23:11:23.929Z] [Client 8] Connection now encrypted.
I [2020-10-30T23:11:23.930Z] [Client 8] GET https://localhost:8000/style.css HTTP/1.1
I [2020-10-30T23:11:23.930Z] [Client 8] OK text/css 8671
I [2020-10-30T23:11:23.932Z] [Client 9] Connection now encrypted.
I [2020-10-30T23:11:23.932Z] [Client 10] Connection now encrypted.
I [2020-10-30T23:11:23.932Z] [Client 9] GET https://localhost:8000/test/icon-md.png HTTP/1.1
I [2020-10-30T23:11:23.935Z] [Client 9] OK image/png 6292
I [2020-10-30T23:11:23.932Z] [Client 8] GET https://localhost:8000/navicon.png HTTP/1.1
I [2020-10-30T23:11:23.936Z] [Client 8] OK image/png 3359
I [2020-10-30T23:11:26.006Z] [Client 9] GET https://localhost:8000/test/ HTTP/1.1
I [2020-10-30T23:11:26.006Z] [Client 9] OK text/html 0
I [2020-10-30T23:11:26.006Z] [Client 9] Closing connection from 'localhost'.
I [2020-10-30T23:11:26.039Z] [Client 8] GET https://localhost:8000/style.css HTTP/1.1
I [2020-10-30T23:11:26.039Z] [Client 8] OK text/css 8671
I [2020-10-30T23:11:27.692Z] [Client 8] GET https://localhost:8000/test/media HTTP/1.1
I [2020-10-30T23:11:27.692Z] [Client 8] OK text/html 0
I [2020-10-30T23:11:27.692Z] [Client 8] Closing connection from 'localhost'.
I [2020-10-30T23:11:27.739Z] [Client 10] GET https://localhost:8000/navicon.png HTTP/1.1
I [2020-10-30T23:11:27.739Z] [Client 10] Not Modified
I [2020-10-30T23:11:27.740Z] [Client 10] Closing connection from 'localhost'.
I [2020-10-30T23:11:29.546Z] [Client 11] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.546Z] [Client 12] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.547Z] [Client 11] Starting HTTPS session.
I [2020-10-30T23:11:29.547Z] [Client 12] Starting HTTPS session.
E [2020-10-30T23:11:29.549Z] [Client 12] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:29.549Z] [Client 12] Closing connection from 'localhost'.
E [2020-10-30T23:11:29.550Z] [Client 11] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:29.550Z] [Client 11] Closing connection from 'localhost'.
I [2020-10-30T23:11:29.559Z] [Client 13] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.560Z] [Client 13] Starting HTTPS session.
I [2020-10-30T23:11:29.564Z] [Client 13] Connection now encrypted.
I [2020-10-30T23:11:29.564Z] [Client 13] GET https://localhost:8000/test/ HTTP/1.1
I [2020-10-30T23:11:29.564Z] [Client 13] OK text/html 0
I [2020-10-30T23:11:29.564Z] [Client 13] Closing connection from 'localhost'.
I [2020-10-30T23:11:29.601Z] [Client 14] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.602Z] [Client 14] Starting HTTPS session.
I [2020-10-30T23:11:29.603Z] [Client 15] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.604Z] [Client 15] Starting HTTPS session.
E [2020-10-30T23:11:29.606Z] [Client 14] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:29.606Z] [Client 14] Closing connection from 'localhost'.
E [2020-10-30T23:11:29.606Z] [Client 15] Unable to encrypt connection: A TLS fatal alert has been received.
I [2020-10-30T23:11:29.606Z] [Client 15] Closing connection from 'localhost'.
I [2020-10-30T23:11:29.607Z] [Client 16] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.607Z] [Client 17] Accepted connection from 'localhost'.
I [2020-10-30T23:11:29.607Z] [Client 16] Starting HTTPS session.
I [2020-10-30T23:11:29.608Z] [Client 17] Starting HTTPS session.
I [2020-10-30T23:11:29.613Z] [Client 16] Connection now encrypted.
I [2020-10-30T23:11:29.613Z] [Client 17] Connection now encrypted.
I [2020-10-30T23:11:29.614Z] [Client 16] GET https://localhost:8000/style.css HTTP/1.1
I [2020-10-30T23:11:29.614Z] [Client 17] GET https://localhost:8000/test/icon-md.png HTTP/1.1
I [2020-10-30T23:11:29.614Z] [Client 17] OK image/png 6292
I [2020-10-30T23:11:29.614Z] [Client 16] OK text/css 8671
I [2020-10-30T23:11:59.642Z] [Client 16] Closing connection from 'localhost'.
I [2020-10-30T23:11:59.642Z] [Client 17] Closing connection from 'localhost'.

OAuth Support

OAuth seems to be where cloud-based printing is going and PAPPL will need to support it for Proxies as well as normal print server operations. Tasks:

  • Import mOAuth client code and adapt for use with proxy and server (introspection).
  • Add support for URL authentication services that force the use of OAuth instead of PAM.

Admin and print groups should map to OAuth scopes.

Web Interface: Other issues/enhancements

Printing Defaults is missing values for the following:

  • Orientation
  • Print Speed
  • Print Darkness

Would also be nice to see:

  • Access to log file (for file-based logging)

PAPPL-based Printer Applications do not DNS-SD-advertise their printers

Describe the bug
I have created the PostScript Printer Application and when I create printers on it, they do not get advertised via DNS-SD, so the CUPS daemon on the same system does not see them and I cannot print via CUPS. The printers actually print, but I can print only using the Printer Application itself. The same I have already observed with the hp-printer-app, but now I cannot reproduce it as the hp-printer-app is currently not working.
Problem also occurs with hp-printer-app.
This is not a problem of Snap confinement. I have changed to the "avahi-control" interface in the PostScript Printer Application and this only leads to the system being advertised, not the printers.

To Reproduce
Fire up a Printer Application using PAPPL as a server, I used ps-printer-app any other, like hp-printer-app should also work.

ps-printer-app -o log-level=debug server

In the web interface click the "Add Printer" button. Then fill in the fields. Enter a queue name, then select your printer from the discovered devices, any entry. Select an arbitrary driver. Confirm. You see the created printer on the front page of the web interface. It does not matter whether you can actually print with it (having a suitable driver, hitting issue #52).
Now run

avahi-browse -t -r -a | grep 'PS Printer App'

and you find only entries of _ipps-system._tcp type, not of _ipp._tcp or _ipps._tcp type.
Run

avahi-browse -t -r _ipp._tcp
avahi-browse -t -r _ipps._tcp

and there is no entry comming from the Printer Application (you see your system's CUPS queues, remote CUPS queues, network printers, ..., grep for port 8000 or for the queue name you assigned, nothing).

lpstat -v

naturally also does not show your Printer Application's printer.

Expected behavior
Printers from the Printer Application get DNS-SD-advertised and so your local CUPS (and cups-browsed) see them and you can print on them from your desktop, without manually creating CUPS queues.

System Information:

  • Ubuntu 20.10 Groovy Gorilla
  • Avahi 0.8.0 (supports localhost)
  • PAPPL: Current GIT snapshot

Localization support

Add support for localization of the web interface using any string resource files that are added.


Breaking this down into sub-tasks:

  • Add pappl_loc_t type and structure to hold per-printer localization information.
  • Add cups_array_t *localizations array to pappl_system_t structure to cache the various localizations.
  • Add pappl_loc_t *papplSystemFindLoc(pappl_system_t *system, pappl_printer_t *printer, const char *language), papplLocFormatString(pappl_loc_t *loc, char *buffer, size_t bufsize, const char *key, ...), and const char *papplLocGetString(pappl_loc_t *loc, const char *key) APIs, plus corresponding private functions _papplLocCreate and _papplLocDelete.
  • Add pappl_loc_t *papplClientGetLoc(pappl_client_t *client) API to return the localization associated with the client's Accept-Language header.
  • Update papplClientHTMLPrintf and papplClientHTMLPuts to try localizing their inputs using the (cached) localization info and to set/restore the POSIX locale so that numbers are formatted properly.
  • Add base localizations for EFIGS
  • Add unit tests

Might be able to internally base the caching on the strings files we are pulling instead of just on the printer since many printer applications won't use per-printer localization files but instead set them at the system level.

Investigate PDF support options

It would be nice to have a solution for providing direct PDF printing support, both for raster printers as well as native PDF printers/print solutions and legacy PostScript devices. Currently the available options are not ideal:

  • CoreGraphics is only available on Apple operating systems
  • MuPDF has an unstable API (with no apparent timeline for having a stable API) and its usage of AGPL can be problematic
  • Ghostscript's code base is difficult to embed and its usage of AGPL can be problematic
  • Poppler (as used by cups-filters) is C++-based and only solves the PDF-to-PostScript and PDF-to-PDF part of the problem (which might be sufficient) and its usage of GPL can be problematic
  • Xpdf (which is what Poppler is based on) is C++-based and its usage of GPL can be problematic

Most of these have commercial licensing options if you need to do a closed-source implementation.

Feature list:

  • (Preferred) C API
  • (Preferred) Apache/MIT/BSD license and/or FRAND commercial license pricing
  • Support for current PDF 2.0 (ISO 32000-2), including color management and document security features
  • Support for rasterizing to the basic Apple/PWG Raster color spaces and bit depths: 1-bit black, 8-bit grayscale w/2.2 gamma ("sGray"), and 24-bit sRGB. (Even better if it supports AdobeRGB, CMYK, etc. with ICC-based color profiles)
  • Support for rendering as PDF, accounting for page-ranges and print-color-mode/color-supported (for monochrome output).
  • Support for rendering as Level 2 PostScript, accounting for page-ranges and print-color-mode/color-supported (for monochrome output) - this is just "nice to have" as most PostScript laser printers also support PCL raster.

When printing to a network printer host name does not get resolved from device URI, job falls into infinite, uninterruptable

Describe the bug
I start a Printer Application, in my case my PostScript Printer Application using debug mode:

ps-printer-app -o log-level=debug server

Then I add a printer via the web interface (see screenshot below). My HP OfficeJet 8730 (DNS-SD record below) is discovered as network printer via DNS-SD and vis SNMP. I have selected the entry resulting from the DNS-SD discovery of the printer. I select the correct model under "Driver".
Creating the printer, setting the media and other default options works.
Now I try to print. To do so I run

ps-printer-app -d test2 PDF-FILE

The Printer Application processes the job data correctly and according to my option settings (via USB connection the printer actually prints) but is not able to resolve my network printer's host name or IP from the device URI it created during printer setup.
See the console output below (it is the debug output of the Printer Application running as server, which I started in the same terminal), especially it shows

D [2020-10-27T11:09:05.522Z] papplSystemFindPrinter: printer 'test2' - resource="/ipp/print/test2", printer_id=2, device_uri="socket://HP%5C032OfficeJet%5C032Pro%5C0328730%5C032%5C09108C229%5C093._pdl-datastream._tcp.local/"
[...]
E [2020-10-27T11:09:05.523Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known
E [2020-10-27T11:09:05.523Z] [Printer test2] Unable to open device 'socket://HP%5C032OfficeJet%5C032Pro%5C0328730%5C032%5C09108C229%5C093._pdl-datastream._tcp.local/', pausing queue until printer becomes available.

There is probably some problem with the parsing/quoting/ecoding/decoding of the DNS-SD service name in the device URI to extract the correct network host name (or IP address) of the printer, needed to send the job to the printer's port 9100.
In addition, even that it is told that the queue got paused by this, the job is retried infinitelt by the Printer Application and there is no way to stop it.
I tried

ps-printer-app shutdown

from another terminal and

killall ps-printer-app

from the same terminal. This did not terminate ps-printer-app nor the job repetition. I had to enter

killall -9 ps-printer-app

to stop it.
The problem must be in PAPPL as PAPPL provides the functionality of discovering printers, assign device URIs to them, and resolving these device URIs to hostname or IP when a job is about to be printed. PAPPL also handles job failures.
I also observed the same with hp-printer-app, but this Printer Application is currently not working, so I cannot use it for reproducing the problem currently.

To Reproduce
You need a printer which advertises itself via DNS-SD and uses a PAPPL-supported network protocol, like socket printing on port 9100. The command

avahi-browse -t _pdl-datastream._tcp

must list the printer.

Fire up a Printer Application using PAPPL as a server, I used ps-printer-app any other, like hp-printer-app should also work.

ps-printer-app -o log-level=debug server

In the web interface click the "Add Printer" button. Then fill in the fields. Enter a queue name, then select your printer from the discovered devices, the entry containing "DNS-SD". Select a suitable driver. Confirm and then set the media which you have in your printer's trays and additional options, like Duplex.
Now print a job, using the command

ps-printer-app FILE

Observe the debug output, you get repeated messages about a hostname/URI resolution problem.
From another terminal window try to stop the mess. Run

ps-printer-app shutdown

and see the error flooding in the fiurst terminal going on.
Also

killall ps-printer-app

does not help. The only solution is

killall -9 ps-printer-app

Expected behavior

  • Jobs can also be printed on network printers and should not fail on URI/hostname/IP resolution.
  • A failing job should actually pause, at least after some attempts (ideally configurable)
  • It must be possible to shut down the server with the standard command even if a failing job is still repeating

System Information:

  • Ubuntu 20.10 Groovy Gorilla
  • Snap built with Ubuntu 20.04 Focal Fossa, snap base is core18, but also manual "quick and dirty" build of ps-printer-app shows the problem.
  • PAPPL is current GIT snapshot

My printer:
HP OfficeJet 8730

$ avahi-browse -t -r _pdl-datastream._tcp
+ enx00e04c043270 IPv4 HP OfficeJet Pro 8730 [08C229]                PDL Printer          local
= enx00e04c043270 IPv4 HP OfficeJet Pro 8730 [08C229]                PDL Printer          local
   hostname = [HP18602408C229.local]
   address = [10.0.0.3]
   port = [9100]
   txt = ["Scan=T" "Duplex=T" "Color=T" "UUID=dbcc4b58-fc4c-f6fd-b4d6-2b00d554ad47" "mopria-certified=1.3" "note=" "adminurl=http://HP18602408C229.local." "mac=18:60:24:08:c2:29" "priority=40" "usb_MDL=OfficeJet Pro 8730" "usb_MFG=HP" "product=(HP OfficeJet Pro 8730)" "ty=HP OfficeJet Pro 8730" "kind=document,envelope,photo,postcard" "PaperMax=legal-A4" "pdl=application/vnd.hp-PCL,application/vnd.hp-PCLXL,application/postscript,application/pdf,image/jpeg,application/PCLm,image/urf,image/pwg-raster" "qtotal=1" "txtvers=1"]

Additional context
Screen shot of printer setup:
Screenshot from 2020-10-27 11-58-52

Console output when printing:

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ ps-printer-app -d test2 ~/ghostscript/testfiles/CityMap.pdf 
I [2020-10-27T11:09:05.522Z] [Client 36] Accepted connection from 'localhost'.
I [2020-10-27T11:09:05.522Z] [Client 36] POST http://localhost:0/ipp/print/test2 HTTP/1.1
I [2020-10-27T11:09:05.522Z] [Client 36] Continue
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request: IPP/2.0 request-id=1
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request: operation-attributes-tag
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request:   attributes-charset charset utf-8
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request:   attributes-natural-language naturalLanguage en-us
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request:   printer-uri uri ipp://localhost/ipp/print/test2
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request:   requesting-user-name nameWithoutLanguage till
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request:   job-name nameWithoutLanguage CityMap.pdf
D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job request:   document-name nameWithoutLanguage CityMap.pdf
D [2020-10-27T11:09:05.522Z] papplSystemFindPrinter(system, resource="/ipp/print/test2", printer_id=0, device_uri="(null)")
D [2020-10-27T11:09:05.522Z] papplSystemFindPrinter: printer 'test' - resource="/ipp/print/test", printer_id=1, device_uri="usb://HP/HP%20OfficeJet%20Pro%208730?serial=CN783F60W1"
D [2020-10-27T11:09:05.522Z] papplSystemFindPrinter: printer 'test2' - resource="/ipp/print/test2", printer_id=2, device_uri="socket://HP%5C032OfficeJet%5C032Pro%5C0328730%5C032%5C09108C229%5C093._pdl-datastream._tcp.local/"
D [2020-10-27T11:09:05.522Z] papplSystemFindPrinter: Returning 0x7fe0d40153e0(test2)
D [2020-10-27T11:09:05.522Z] [Client 36] Auto-type header: 255044462D312E34... format: application/pdf

D [2020-10-27T11:09:05.522Z] [Client 36] Print-Job Auto-typed "document-format"='application/pdf'.
D [2020-10-27T11:09:05.522Z] [Job 1] Created job file "/tmp/pappl366365.d/p00002j000000001-citymap_pdf.pdf", format "application/pdf".
D [2020-10-27T11:09:05.522Z] [Printer test2] Checking for new jobs to process.
D [2020-10-27T11:09:05.523Z] [Printer test2] Starting job 1.
I [2020-10-27T11:09:05.523Z] [Client 36] Print-Job successful-ok
I [2020-10-27T11:09:05.523Z] [Client 36] OK application/ipp 214
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response: IPP/2.0 request-id=1, status-code=successful-ok
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response: operation-attributes-tag
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   attributes-charset charset utf-8
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   attributes-natural-language naturalLanguage en-us
I [2020-10-27T11:09:05.523Z] [Job 1] Starting print job.
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response: job-attributes-tag
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   job-id integer 1
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   job-uri uri ipp://localhost/ipp/print/test2/1
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   job-state enum pending
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   job-state-message textWithoutLanguage Job pending.
D [2020-10-27T11:09:05.523Z] [Client 36] Print-Job response:   job-state-reasons keyword none
test2-1
I [2020-10-27T11:09:05.523Z] [Client 36] Closing connection from 'localhost'.
E [2020-10-27T11:09:05.523Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known
E [2020-10-27T11:09:05.523Z] [Printer test2] Unable to open device 'socket://HP%5C032OfficeJet%5C032Pro%5C0328730%5C032%5C09108C229%5C093._pdl-datastream._tcp.local/', pausing queue until printer becomes available.
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ I [2020-10-27T11:09:06.523Z] Saving system state to '/tmp/ps_printer_app.state'.

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ E [2020-10-27T11:09:10.523Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ E [2020-10-27T11:09:15.523Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known
E [2020-10-27T11:09:20.523Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known
I [2020-10-27T11:09:22.094Z] [Client 37] Accepted connection from 'localhost'.
I [2020-10-27T11:09:22.094Z] [Client 37] POST http://localhost:0/ipp/system HTTP/1.1
I [2020-10-27T11:09:22.094Z] [Client 37] Continue
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 request: IPP/2.0 request-id=1
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 request: operation-attributes-tag
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 request:   attributes-charset charset utf-8
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 request:   attributes-natural-language naturalLanguage en-us
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 request:   system-uri uri ipp://localhost/ipp/system
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 request:   requesting-user-name nameWithoutLanguage till
D [2020-10-27T11:09:22.094Z] papplSystemFindPrinter(system, resource="(null)", printer_id=0, device_uri="(null)")
D [2020-10-27T11:09:22.094Z] papplSystemFindPrinter: printer 'test' - resource="/ipp/print/test", printer_id=1, device_uri="usb://HP/HP%20OfficeJet%20Pro%208730?serial=CN783F60W1"
D [2020-10-27T11:09:22.094Z] papplSystemFindPrinter: printer 'test2' - resource="/ipp/print/test2", printer_id=2, device_uri="socket://HP%5C032OfficeJet%5C032Pro%5C0328730%5C032%5C09108C229%5C093._pdl-datastream._tcp.local/"
D [2020-10-27T11:09:22.094Z] papplSystemFindPrinter: Returning (nil)(none)
I [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 successful-ok
I [2020-10-27T11:09:22.094Z] [Client 37] OK application/ipp 75
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 response: IPP/2.0 request-id=1, status-code=successful-ok
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 response: operation-attributes-tag
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 response:   attributes-charset charset utf-8
D [2020-10-27T11:09:22.094Z] [Client 37] 0x0063 response:   attributes-natural-language naturalLanguage en-us
I [2020-10-27T11:09:22.095Z] [Client 37] Closing connection from 'localhost'.
E [2020-10-27T11:09:25.524Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ E [2020-10-27T11:09:30.524Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ E [2020-10-27T11:09:35.524Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ killall E [2020-10-27T11:09:40.524Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known
pE [2020-10-27T11:09:45.525Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ killall ps-printer-app
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ killall ps-printer-appE [2020-10-27T11:09:50.525Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not known

till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ killall -9E [2020-10-27T11:09:55.525Z] [Device] Unable to lookup \'HP\\032OfficeJet\\032Pro\\0328730\\032\\09108C229\\093._pdl-datastream._tcp.local:9100\': Name or service not knowtill@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
 ps-printer-app
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
[1]+  Killed                  ps-printer-app -o log-level=debug server
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ 

macOS: Add menu extra showing status of system/printers

For macOS, add a menu extra for the system and its printers. The menu extra should convert the favicon image into a template image, and then expose the following menu items:

  • System name (opens system home page when selected)
  • System version (disabled menu item)
  • Menu separator
  • For each printer:
    • Printer name (opens printer home page when selected)
    • Printer status (disabled menu item) with alerts
    • Active job (if any) including job name (disabled menu item)
  • Menu separator
  • "Quit "

The menu extra should appear whenever the system is run.

Web interface needs a driver-auto-select button, "add" subcommand a driver auto-select option

Is your feature request related to a problem? Please describe.
Currently, if you add a printer on a Printer Application you always have to select the driver manually, both in the web interface and with the "add" command line subcommand.
This is not such a big problem with hp-printer-app with only 3 drivers to choose from but gets awkward with a Printer Application like ps-printer-app with ~4000 drivers (= printer models) to choose from. The long list comes in handy if your printer is not explicitly under these 4000 and you want to select a similar one, but if you want to quickly add a discovered printer, an "Automatically Select Driver" button wold be very helpful.
Also on the command line one could have the possibility to supply -m auto for the Printer Application automatically to select the best driver for the discovered printer (as supplied by -v ....
To implement this, the Printer Application can simply call the autoadd callback function with the device ID of the printer, getting back the name of the best driver. If the printer is unsupported the autoadd callback returns NULL and so the "add" subcommand could return an error message to the user and not add the printer. In case of the web interface an error message telling that the printer is not supported would be shown.

Describe the solution you'd like
Web interface: Add "Automatically Select Driver" button to the page for adding a printer. Then user does not need to select driver from drop-down list.
Command line: With the "add" subcommand allow also -m auto for automatic driver selection.
Use autoadd callback function to determine the best driver.

Describe alternatives you've considered
Add driver named "auto" as very first entry to the driver list of the Printer Application (so that the long list of drivers starts with "Automatic Selection" and also -m auto with the "add" subcommand is accepted). If the user selects this when adding a printer the driver callback (ps-callback() in ps-printer-app.c) has to determine which driver actually to choose, but this callback does not get the device ID of the printer and so this is not possible.

autoadd only works with hard-coded driver list

Describe the bug
My PostScript Printer Application generates the list of available drivers based on the PPD files available in the Snap (or generally in pre-defined directories) instead of hard-coding them in the code of the Printer Application itself (as hp-printer-app does).
With the fix of issue #42 I am now able to build the driver list out of the system_cb() callback, by calling ps_setup() after creating the system. This way I can create the driver list when the system is already there, to be able to log the driver list creation process.
Now I have a server running (which has its driver list built, as a server requires to create a system) and want to auto-add the available printers.
So I run ps-printer-app autoadd, the available printers get auto-added, but all with the "generic" driver using a "Generic PostScript Printer" PPD and not the PPD for the detected printer. This happens because the autoadd callback (ps_autoadd() in ps-printer-app.c) is run without having a driver list, as ps-printer-app autoadd does not create a system (as ps-printer-app drivers does) nor does it somehow load the driver list from the server process (is this possible?), nor does it simply send the "autoadd" command to the server process and the server process does everything then.
The ps-printer-app autoadd does nothing more than only asking the server to auto-discover the printers, not to assign drivers to them. The drivers it tries to assign the drivers by itself, which fails (fallback to "generic") as it did not obtain the driver list first, neither by creating a system nor by somehow downloading it from the server.

To Reproduce
Download the source code of the PostScript Printer Application, build the Snap (it takes automatically care of using the current GIT snapshots of PAPPL and cups-filters), and install it. Connect one of the ~4000 supported PostScript printers. Then run

ps-printer-app -o log-level=debug server &
ps-printer-app -o log-level=debug autoadd

Your printer will get added, but with the "generic" driver and not the one specific to your printer model. You see it by the debug logging and also in the state file (/tmp/snap.ps-printer-app/tmp/ps_printer_app.state).

ps-printer-app drivers

shows that your printer deserves something better.
Do not try to determine the driver selected by the web interface, some of the recent PAPPL commits seems to have broken the media and default options parts (another issue report to come here).

Expected behavior
When calling

ps-printer-app autoadd

PAPPL should do one of the following three things to make "autoadd" work correctly:

  1. Create a system, as ps-printer-app drivers does, then do the autoadd as before
  2. Add a new function to PAPPL's server IPP to allow a client to download the driver list, then let ps-printer-app autoadd download the driver list before doing the autoadd as before
  3. Add a new function to PAPPL's server IPP to simply accept an "autoadd" command, then let ps-printer-app autoadd send this command and the server does the actual process of auto-adding completely

I prefer (3) here as with ~4000 supported printers building the driver list takes several seconds. The server has the list readily available and so simply triggering auto-adding on the server would be the fastest, most efficient, and least memory-consuming.

And once adding such an "autoadd" command to the server's IPP interface, add "drivers", too instead of the client having to build the driver list separately.

And please do not tell me to build the driver list in the main() function before calling papplMainloop() as then I cannot log the driver list build process (issue #42).

System Information:

  • Ubuntu, Focal Fossa 20.04 to build Snaps, problem occurs on both 20.04 and 20.10.
  • PAPPL, cups-filters, and ps-printer-app are current GIT snapshots.

When printing JPG image with Printer Application the Printer Application crashes

Describe the bug
After having added raster callbacks to my PostScript Printer Application to support PWG/Apple Raster I have tried to switch image printing from the cups-filters-based approach to PAPPL's built-in image input support which uses the raster callbacks.
I send a photo in landscape orientation. PAPPL's papplJobFilterImage() function automatically rotates the image counterclockwise to fit it into the page. When sending the raster image the Printer Application crashes mid-way. From the image data I have found out that for landscape-oriented pictures the pointer to the first pixel to grab in the original image buffer is wrong and so only the last forth of the image is sent and after that the pointer goes beyond the buffer and the Printer Application crashes.
Following patch fixes this:

--- a/pappl/job-filter.c
+++ b/pappl/job-filter.c
@@ -180,7 +180,7 @@ papplJobFilterImage(
 	break;
 
     case IPP_ORIENT_LANDSCAPE : // 90 counter-clockwise
-        pixbase    = pixels + width - depth;
+        pixbase    = pixels + width * depth - depth;
         img_width  = height;
         img_height = width;
         xdir       = (int)depth * (int)width;
@@ -329,7 +329,16 @@ papplJobFilterImage(
 	for (x = xstart, lineptr = line + x * bpp, xerr = -xmod / 2; x < xend; x ++)
 	{
 	  // Copy a grayscale or RGB pixel...
-	  memcpy(lineptr, pixptr, bpp);
+	  if (pixptr < pixels || pixptr > pixels + width * height * bpp)
+	  {
+	    if (pixptr < pixels)
+	      papplLogJob(job, PAPPL_LOGLEVEL_DEBUG, "Accessed %ld bytes below original image space", pixels - pixptr);
+	    else
+	      papplLogJob(job, PAPPL_LOGLEVEL_DEBUG, "Accessed %ld bytes above original image space", pixptr - pixels - width * height * bpp);	      
+	    papplLogJob(job, PAPPL_LOGLEVEL_DEBUG, "width=%d, height=%d, bpp=%d, y=%d, ysize=%d, ydir=%d, x=%d, xstart=%d, xend=%d, xsize=%d, xdir=%d, xstep=%d, xmod=%d, xerr=%d", width, height, bpp, y, ysize, ydir, x, xstart, xend, xsize, xdir, xstep, xmod, xerr);
+	  }
+	  else
+	    memcpy(lineptr, pixptr, bpp);
 	  lineptr += bpp;
 
 	  // Advance to the next pixel...

The actual fix is the first part of the patch, the second part is a crash guard which prevents a pixel from being grabbed from the original image if the pointer is beyond the buffer. In this case a debug message is shown. Even with the fix I recommend the crash guard being applied, to assure that rounding errors cannot crash the Printer Application.

To Reproduce
Take a Printer Application and print a photo in landscape orientation, some time into the process the Printer Application crashes.
Note that the PostScript Printer Application as currently on the GIT uses (still) cups-filters to print photos and so the crash does not occur.

System Information:

  • As usual, all current GIT snapshots on Ubuntu 20.04

In the TXT record of the DNS-SD broadcast of an emulated IPP printer "pdl" is "("

I have run testpappl to try out the Printer Application framework. The test setup emulates two IPP printers. I can create CUPS queues using

lpadmin -p printer -E -v URI -m everywhere

and print on these queues, but I do not get any auto discovery of these printers, for example by the driverless utility or by cups-browsed from cups-filters. In the output of avahi-discover (or avahi-browse) I have seen thst tha PDL entry in the TXT record of the emulated printers is broken, and auto-discovery tools like driverless or cups-browsed identify driverless-capable IPP printers by the PDLs which get advertised for them. The "pdl" field in the TXT record is always simply "(" which does not make sense. It looks like that some pointer is pointing to something wrong.

Jobs: Add pager and cancel buttons to web interface

Right now the web interface doesn't limit the number of jobs shown on the home page, and doesn't allow the user to cancel a job (or all jobs).

  • Add pager to jobs list
  • Add Cancel button to not-completed jobs
  • Add Cancel All Jobs button

Finish support for vendor options

The current support for vendor/custom options is lacking and needs to be completed before 1.0. Specific changes:

  • Add cups_option_t array to pappl_joptions_t with vendor options
  • Change papplJobGetOptions to allocate the pappl_joptions_t structure.
  • Add papplJobFreeOptions function to free the pappl_joptions_t structure along with any allocated vendor options
  • Add vendor options and attributes to the PWG test driver
  • Add web UI for vendor options
  • Add support for vendor options at the command-line

Entries for discovered printers are cryptic

Describe the bug
I am testing with the HP printer sample app hp-printer-app. When adding a new printer in the web interface (https://localhost:8000/addprinter) the discovered printer devices listed under "Devices:" are represented by cryptic, very long strings, where normal end users do not know which one to choose (the best is merge PR #36 ASAP, but manual addition is still often needed).

In case of a discovered network printer the DNS-SD-based URI seems not to get completely decoded, in the list appears HP\032OfficeJet\032Pro\0328730\032\09108C992\093 instead of HP OfficeJet Pro 8730 [08C992].

For USB printers there are 3 problems:

  1. There are 2 identical entries
  2. "HP" is duplicate: USB HP HP OfficeJet Pro 8730 ...
  3. After the model name appears a very long string of digits, like (05000009000009000009000009000009, 12000, 170000000000000000000000000000)

As Printer Applications should get the standard way to provide printer drivers they need to be usable also for normal end users, who simply want to print.

To Reproduce
Follow the steps to build the hp-printer-app in Issue #39. You will reach the problem described here before it comes to the crash described there.
Start the app as a server: ./hp-printer-app server.
In a browser open the web interface and click the button to add a printer. Click on the drop-down of "Devices:". Then you see the cryptic entries described above. You need a printer in your network/on your USB.

Expected behavior
Clear, user-friendly entries in the "Devices:" drop-down:

  • HP OfficeJet Pro 8730, Network host HOST_NAME (IP)
  • HP OfficeJet Pro 8730, USB, Serial No. 12345678

System Information:
Same as in Issue #39

Devices: Add SNMP discovery/printing

Add support for printer discovery and lookup using SNMP, a la the CUPS snmp backend. Focus should be on using SNMPv1 with the "public" community name (default), although perhaps this could be configurable. And SNMP should only find AppSocket/JetDirect printers.

The identifier (name) OID is:

  • SNMPv2-MIB::sysName.0 (.1.3.6.1.2.1.1.5.0)

The IEEE 1284 Device ID OIDs are:

  • HP: .1.3.6.1.4.1.11.2.3.9.1.1.7.0
  • Lexmark: 1.3.6.1.4.1.641.2.1.2.1.3.1
  • PWG PPM: 1.3.6.1.4.1.2699.1.2.1.2.1.1.3.1
  • Zebra: .1.3.6.1.4.1.10642.1.3.0

Browse for: HOST-RESOURCES-MIB::hrDeviceType.1 = OID: HOST-RESOURCES-TYPES::hrDevicePrinter (.1.3.6.1.2.1.25.3.2.1.2.1 = OID: .1.3.6.1.2.1.25.3.1.5)

papplDeviceList should return URIs of the form "snmp://sysName" where "sysName" is the SNMP sysName string. papplDeviceOpen then looks up the sysName to get the IP address (since that will likely come from DHCP...) and uses socket over port 9100.

Web Interface Enhancements

The current web interface is missing some necessary controls for IPP Everywhere and other IPP-based standards:

  • View/change DNS-SD Service Name (e.g. "Printer Name")
  • View/change location string (e.g. "Room 42")
  • View/change geo-location (latitude/longitude/altitude)
  • View/change printer certificates
  • View/change user accounts/passwords (for doing printer administration)

papplMain()?

Would be interesting to provide a standard command-line interface for PAPPL-based printer applications, like the one that LPrint provides.

Devices: Add DNS-SD/mDNS discovery/printing

Add support for printer discovery and lookup using mDNS/DNS-SD, a la the CUPS dnssd backend, but just for pdl-datastream (AppSocket/JetDirect).

papplDeviceList should return "socket://servicename._pdl-datastream._tcp.local." URIs. papplDeviceOpen should resolve the service name and then connect to the socket.

Jobs: Support for job-hold-until/Hold-Job/Release-Job

Would be nice to support held jobs. Tasks:

  • Support job-hold-until/-time Job Template attribute and associated Printer attributes
  • Support Hold-Job and Release-Job operations
  • Support Hold-New-Jobs and Release-Held-New-Jobs operations (admin)
  • Add Hold/Release Job button to Jobs web interface (with auth challenge when needed)
  • Add Hold/Release Jobs button to Printer web interface (with auth challenge when needed)

IPP-USB Gadget Support

Develop a Linux USB gadget and corresponding support code in PAPPL to allow communication with the default printer in PAPPL using the IPP-USB protocol. References:

There are two parts to this:

  • A kernel driver, either an updated version of the USB printer gadget or a new g_ippusb gadget. The gadget needs to expose at least three pairs of endpoints to support printing and scanning simultaneously. Descriptor limits may be an issue.
  • Support code in PAPPL to basically map the endpoints to local sockets, either localhost or (better) a domain socket listener.

This code should coexist with the USB printer gadget - the client device can only select the legacy printer class or the new IPP-USB class (not both), but the PAPPL code needs to properly handle that selection.

With PWG/Apple Raster input papplJobCreatePrintOptions() is called with num_pages = 0, clobbering the Duplex default setting

Describe the bug
In my PostScript Printer Application I set long-edge duplex as default in the web interface. PDF and PostScript input files get correctly printed double sided. To prepare these jobs I call the papplJobCreatePrintOptions() function of PAPPL in the ps_filter() function in ps-printer-app.c, with num_pages set to INT_MAX, as I do not know beforehand how many pages my PDF or PostScript file has.
If I send a PWG/Apple Raster job, PAPPL calls the papplJobCreatePrintOptions() function in the _papplJobProcessRaster() function, but if the input stream has no number of pages info, it uses 0 for num_pages. This does not stop PAPPL from printing the whole job with any number of pages, but it breaks the default setting for duplex.
papplJobCreatePrintOptions() sets the duplex option for the job as follows:

  // sides
  if ((attr = ippFindAttribute(job->attrs, "sides", IPP_TAG_KEYWORD)) != NULL)
    options->sides = _papplSidesValue(ippGetString(attr, 0, NULL));
  else if (printer->driver_data.sides_default != PAPPL_SIDES_ONE_SIDED && options->num_pages > 1)
    options->sides = printer->driver_data.sides_default;
  else
    options->sides = PAPPL_SIDES_ONE_SIDED;

If num_pages is 0 or 1, the default sides is overridden and always PAPPL_SIDES_ONE_SIDED selected, due to the && options->num_pages > 1. If you want to set num_pages to 0 to tell that the actual number of pages is not known, you should use && options->num_pages != 1 instead. Or call papplJobCreatePrintOptions() with INT_MAX to tell that the number of pages is unknown.

To Reproduce
Create a PWG/Apple Raster file WITHOUT number of pages in the first page's header but with more than one page, the Raster files of cups-filters (I used the gstoraster filter) generates such files. In the PostScript Printer Application (any other should show the problem, too) create a printer and set the default for 2-sided printing to one of the "On" choices. Print your Raster file with this printer, not specifying the "sides" option on the command line. The printout comes out single-sided. Print a multi-page PDF file and the printout is correctly double-sided.

There should be a reserved value for num_pages to tell that the number of pages is unknown, can be 0, -1, or INT_MAX, and it should be mentioned in the source code and in the documentation.

Expected behavior
All multi-page jobs correctly double-sided, independent of input format.

System Information:

  • Ubuntu 20.10 Groovy
  • Current GIT snapshots of ps-printer-app, PAPPL, and cups-filters

IPP INFRA/SYSTEM Server Support

Add support for IPP INFRA (PWG 5100.18) and SYSTEM (PWG 5100.22) to function as an infrastructure printer. Tasks:

  • IPP Notifications (RFC 3995/3996) support
  • IPP System service - notifications
  • IPP System service - Register-Output-Device
  • Register callback that returns a pappl_printer_t pointer
  • IPP System service - resources
  • Save/load IPP-managed resources
  • Update resource API to support more IPP resource stuff
  • IPP INFRA - printer and job operations
  • "infra" driver name
  • PAPPL_SOPTIONS_INFRA_SERVER to enable INFRA support
  • Transform support (as configured)

When printing an image with "print-scaling=fill" the image is not blown to fully fill the page but printed as with "print-scaling=auto"

Describe the bug
When I set my PostScript Printer Application to print images with PAPPL's built-in image filter using the raster callbacks and I supply the setting "print-scaling=fill", either by setting it as default in the web interface or by supplying the option -o print-scaling=fill on the command line, the setting is ignored and the image printed in standard "auto" mode leaving white borders at two edges.
Debug log shows use of "fill" but image comes out as with "auto":

D [2020-11-06T17:27:22.305Z] [Job 62] Created job file "/tmp/pappl248865.d/p00001j000000062-1221-pb237716_jpg.jpg", format "image/jpeg".
D [2020-11-06T17:27:22.316Z] [Printer test] Checking for new jobs to process.
D [2020-11-06T17:27:22.316Z] [Printer test] Starting job 62.
I [2020-11-06T17:27:22.316Z] [Client 4] Print-Job successful-ok
I [2020-11-06T17:27:22.316Z] [Job 62] Starting print job.
I [2020-11-06T17:27:22.316Z] [Client 4] OK application/ipp 223
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response: IPP/2.0 request-id=2, status-code=successful-ok
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response: operation-attributes-tag
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   attributes-charset charset utf-8
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   attributes-natural-language naturalLanguage en-us
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response: job-attributes-tag
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   job-id integer 62
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   job-uri uri ipp://localhost/ipp/print/test/62
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   job-state enum processing
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   job-state-message textWithoutLanguage Job printing.
D [2020-11-06T17:27:22.316Z] [Client 4] Print-Job response:   job-state-reasons keyword job-printing
test-62
I [2020-11-06T17:27:22.316Z] [Client 4] Closing connection from 'localhost'.
till@till-x1yoga:~/printing/openprinting/ps-printer-app/x$ D [2020-11-06T17:27:22.538Z] [Job 62] Getting options for num_pages=1, color=true
D [2020-11-06T17:27:22.538Z] [Job 62] print-color-mode=monochrome
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsWidth=4960
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsHeight=7015
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsBitsPerColor=8
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsBitsPerPixel=8
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsBytesPerLine=4960
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsColorOrder=0
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsColorSpace=18 (sGray)
D [2020-11-06T17:27:22.538Z] [Job 62] header.cupsNumColors=1
D [2020-11-06T17:27:22.538Z] [Job 62] header.HWResolution=[600 600]
D [2020-11-06T17:27:22.538Z] [Job 62] num_pages=1
D [2020-11-06T17:27:22.538Z] [Job 62] copies=1
D [2020-11-06T17:27:22.538Z] [Job 62] finishings=0x0
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.bottom-margin=0
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.left-margin=0
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.right-margin=0
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.size=21000x29700
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.size-name='iso_a4_210x297mm'
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.source='tray-1'
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.top-margin=0
D [2020-11-06T17:27:22.538Z] [Job 62] media-col.type='stationery'
D [2020-11-06T17:27:22.538Z] [Job 62] orientation-requested=none
D [2020-11-06T17:27:22.538Z] [Job 62] page-ranges=1-1
D [2020-11-06T17:27:22.538Z] [Job 62] print-color-mode='monochrome'
D [2020-11-06T17:27:22.538Z] [Job 62] print-content-optimize='photo'
D [2020-11-06T17:27:22.538Z] [Job 62] print-darkness=0
D [2020-11-06T17:27:22.538Z] [Job 62] print-quality=draft
D [2020-11-06T17:27:22.538Z] [Job 62] print-scaling='fill'
D [2020-11-06T17:27:22.538Z] [Job 62] print-speed=0
D [2020-11-06T17:27:22.538Z] [Job 62] printer-resolution=600x600dpi
I [2020-11-06T17:27:22.538Z] [Job 62] Loading 4608x3456x1 JPEG image.
D [2020-11-06T17:27:22.667Z] [Job 62] ileft=0, itop=0, iwidth=4960, iheight=7015
I [2020-11-06T17:27:22.667Z] [Job 62] Auto-orientation: landscape
D [2020-11-06T17:27:22.667Z] [Job 62] xsize=4960, xstart=0, xend=4960, xdir=4608, xmod=3456, xstep=0
D [2020-11-06T17:27:22.667Z] [Job 62] ysize=6613, ystart=201, yend=6814, ydir=-1
D [2020-11-06T17:27:22.968Z] [Job 62] Adding options for finishings
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: PageSize
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: InputSlot
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: MediaType
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: orientation-requested
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option presets depending on requested print quality
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: print-scaling
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: Resolution
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: Duplex
D [2020-11-06T17:27:22.968Z] [Job 62] Adding option: OutputBin
D [2020-11-06T17:27:22.968Z] [Job 62] PPD options to be used: Duplex=None InputSlot=Tray1 MediaType=Plain orientation-requested=3 page-ranges=1-1 PageSize=A4.FullBleed print-scaling=fill Resolution=600dpi
I [2020-11-06T17:27:22.969Z] [Job 62] filterPOpen: Filter function (PID 248893) started.
I [2020-11-06T17:27:23.301Z] Saving system state to '/tmp/ps_printer_app.state'.
D [2020-11-06T17:27:49.533Z] [Job 62] filterPOpen: Filter function completed with status 0.
D [2020-11-06T17:27:49.535Z] [Job 62] filterPClose: Filter function (PID 248893) exited with no errors.
I [2020-11-06T17:27:49.536Z] [Job 62] Completed, job-impressions-completed=1.
D [2020-11-06T17:27:49.537Z] [Job 62] Device read metrics: 0 requests, 0 bytes, 0 msecs
D [2020-11-06T17:27:49.537Z] [Job 62] Device write metrics: 0 requests, 0 bytes, 0 msecs

Note that I am using the patch of issue #61 to be able to print the image at all.

To Reproduce
Print an image to a Printer Application, with either "print-scaling=fill" set as printer default in the web interface or printing the job with the -o print-scaling=fill command line options. The image comes out with white on two borders (as in "auto" mode) and in the debug log it is also shown that "print-scaling=auto" is used.

System Information:

  • As usual all current GIT snapshots on Ubuntu 10.20.

Add tolerance to rounding errors when sending Apple/PWG Raster

Describe the bug
I have added raster cakkbacks for streaming processing of Apple/PWG Raster input (Issue #57) to my PostScript printer Application, problem is now that I can only reliably print documents with a page size smaller the the printer's page size set in the web interface, for example an A5-sized document on A4-sized paper. If I try printing an A4-sized document on A4-sized paper the job gets aborted with a "Unsupported raster data seen." message in the log.
I looked for this message in PAPPL's source code and found in the _papplJobProcessRaster() function in pappl/job-process.c:

    if (header.cupsWidth > options->header.cupsWidth || header.cupsHeight > options->header.cupsHeight || (header.cupsBitsPerPixel > 8 && !(printer->driver_data.color_supported & PAPPL_COLOR_MODE_COLOR)))
    {
      papplLogJob(job, PAPPL_LOGLEVEL_ERROR, "Unsupported raster data seen.");
      papplJobSetReasons(job, PAPPL_JREASON_DOCUMENT_UNPRINTABLE_ERROR, PAPPL_JREASON_NONE);
      job->state = IPP_JSTATE_ABORTED;
      break;
    }

This means that if the job's pixel count in one (x or y) dimension is larger than the appropriate pixel count for the paper in the printer, or if a color job is sent to a black-and-white printer the job is aborted.
I have a color printer, so only a too large dimension can be the problem here. My printer's data in the Printer Application is based on the same PPD file as I use with cups-filters to turn a PDF file into a PWG Raster file for testing. Problem is that the calculation of pixel counts is not done exactly the same way in PAPPL and cups-filters (and perhaps even another way on other clients, like iOS), leading to rounding errors, pixel counts differing by a small amount, perhaps 1 % or lower. This makes the document's pixel count for the same page size (in PostScript points) for the document and for the Printer Application larger than the printer's pixel count in 50% of the cases, getting the job aborted.
Here we would need some tolerance, accepting also jobs with a dimension by a few pixels to large. We could throw away these extra pixels to avoid any overflows, they are usually white border or at least irrelevant content anyway.
Below is a debug log of such a job. Here you see that the pages of the job have are 4958x7017 pixels but the printer page calculated by PAPPL is 4960x7015 pixels, making the page aborted due to too many raster lines in y dimension:

I [2020-11-04T21:45:32.440Z] [Job 32] Page 1 raster data is 4958x7017x24 (RGB)
D [2020-11-04T21:45:32.440Z] [Job 32] Getting options for num_pages=0, color=true
D [2020-11-04T21:45:32.440Z] [Job 32] print-color-mode=color
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsWidth=4960
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsHeight=7015

I can solve the problem by adding simple tolerance margins:

    if (header.cupsWidth > options->header.cupsWidth +10 || header.cupsHeight > options->header.cupsHeight + 10 || (header.cupsBitsPerPixel > 8 && !(printer->driver_data.color_supported & PAPPL_COLOR_MODE_COLOR)))
    {
      papplLogJob(job, PAPPL_LOGLEVEL_ERROR, "Unsupported raster data seen.");
      papplJobSetReasons(job, PAPPL_JREASON_DOCUMENT_UNPRINTABLE_ERROR, PAPPL_JREASON_NONE);
      job->state = IPP_JSTATE_ABORTED;
      break;
    }

This is not the perfect solution, probably a certain percentage, for example 2 % should be given here, and extra pixels/raster lines being skipped.

To Reproduce
Steps to reproduce the behavior:
Take a PDF document and convert it to a Raster document via

FINAL_CONTENT_TYPE=pwg PPD=hp8730ps.ppd /usr/lib/cups/filter/pdftopdf 1 1 1 1 'PageSize=A4 ColorModel=rgb page-scaling=fill' ~/ghostscript/testfiles/launch_leaflet.pdf | FINAL_CONTENT_TYPE=pwg PPD=hp8730ps.ppd /usr/lib/cups/filter/gstoraster 1 1 1 1 'PageSize=A4 ColorModel=rgb page-scaling=fill' > out.raster

Create a printer with the same PPD file in the PostScript Printer Application. In the options set A4 as page size, mark "Borderless" (if available) and select to print in color. Then print out.raster. The job gets aborted due to the mismatch shown above.

Expected behavior
Job getting printed despite the slight mismatch in raster sizes.

System Information:

  • OS: Ubuntu 20.10 Groovy
  • Current GIT snapshot of the PostScript Printer Application, PAPPL, and cups-filters

Additional context
Debug log of an aborted job due to raster dimension mismatch:

I [2020-11-04T21:45:31.963Z] [Job 32] Starting print job.
D [2020-11-04T21:45:32.137Z] [Job 32] Getting options for num_pages=0, color=true
D [2020-11-04T21:45:32.137Z] [Job 32] print-color-mode=color
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsWidth=4960
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsHeight=7015
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsBitsPerColor=8
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsBitsPerPixel=24
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsBytesPerLine=14880
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsColorOrder=0
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsColorSpace=19 (sRGB)
D [2020-11-04T21:45:32.137Z] [Job 32] header.cupsNumColors=3
D [2020-11-04T21:45:32.137Z] [Job 32] header.HWResolution=[600 600]
D [2020-11-04T21:45:32.137Z] [Job 32] num_pages=0
D [2020-11-04T21:45:32.137Z] [Job 32] copies=1
D [2020-11-04T21:45:32.137Z] [Job 32] finishings=0x0
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.bottom-margin=0
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.left-margin=0
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.right-margin=0
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.size=21000x29700
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.size-name='iso_a4_210x297mm'
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.source='tray-1'
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.top-margin=0
D [2020-11-04T21:45:32.137Z] [Job 32] media-col.type='stationery'
D [2020-11-04T21:45:32.137Z] [Job 32] orientation-requested=none
D [2020-11-04T21:45:32.137Z] [Job 32] page-ranges=1-0
D [2020-11-04T21:45:32.137Z] [Job 32] print-color-mode='color'
D [2020-11-04T21:45:32.137Z] [Job 32] print-content-optimize='auto'
D [2020-11-04T21:45:32.137Z] [Job 32] print-darkness=0
D [2020-11-04T21:45:32.137Z] [Job 32] print-quality=high
D [2020-11-04T21:45:32.137Z] [Job 32] print-scaling='auto'
D [2020-11-04T21:45:32.137Z] [Job 32] print-speed=0
D [2020-11-04T21:45:32.137Z] [Job 32] printer-resolution=600x600dpi
D [2020-11-04T21:45:32.439Z] [Job 32] Adding options for finishings
D [2020-11-04T21:45:32.439Z] [Job 32] Adding option: PageSize
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: InputSlot
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: MediaType
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: orientation-requested
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option presets depending on requested print quality
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: print-scaling
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: Resolution
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: Duplex
D [2020-11-04T21:45:32.440Z] [Job 32] Adding option: OutputBin
D [2020-11-04T21:45:32.440Z] [Job 32] PPD options to be used: Duplex=None InputSlot=Tray1 MediaType=Plain page-ranges=1-0 PageSize=A4.FullBleed print-scaling=auto Resolution=600dpi
I [2020-11-04T21:45:32.440Z] [Job 32] filterPOpen: Filter function (PID 152512) started.
I [2020-11-04T21:45:32.440Z] [Job 32] Page 1 raster data is 4958x7017x24 (RGB)
D [2020-11-04T21:45:32.440Z] [Job 32] Getting options for num_pages=0, color=true
D [2020-11-04T21:45:32.440Z] [Job 32] print-color-mode=color
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsWidth=4960
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsHeight=7015
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsBitsPerColor=8
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsBitsPerPixel=24
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsBytesPerLine=14880
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsColorOrder=0
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsColorSpace=19 (sRGB)
D [2020-11-04T21:45:32.440Z] [Job 32] header.cupsNumColors=3
D [2020-11-04T21:45:32.440Z] [Job 32] header.HWResolution=[600 600]
D [2020-11-04T21:45:32.440Z] [Job 32] num_pages=0
D [2020-11-04T21:45:32.440Z] [Job 32] copies=1
D [2020-11-04T21:45:32.440Z] [Job 32] finishings=0x0
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.bottom-margin=0
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.left-margin=0
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.right-margin=0
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.size=21000x29700
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.size-name='iso_a4_210x297mm'
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.source='tray-1'
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.top-margin=0
D [2020-11-04T21:45:32.440Z] [Job 32] media-col.type='stationery'
D [2020-11-04T21:45:32.440Z] [Job 32] orientation-requested=none
D [2020-11-04T21:45:32.440Z] [Job 32] page-ranges=1-0
D [2020-11-04T21:45:32.440Z] [Job 32] print-color-mode='color'
D [2020-11-04T21:45:32.440Z] [Job 32] print-content-optimize='auto'
D [2020-11-04T21:45:32.440Z] [Job 32] print-darkness=0
D [2020-11-04T21:45:32.440Z] [Job 32] print-quality=high
D [2020-11-04T21:45:32.440Z] [Job 32] print-scaling='auto'
D [2020-11-04T21:45:32.440Z] [Job 32] print-speed=0
D [2020-11-04T21:45:32.440Z] [Job 32] printer-resolution=600x600dpi
E [2020-11-04T21:45:32.440Z] [Job 32] Unsupported raster data seen.

Add accessor functions to printer and job IPP attributes in printer and job data structures

Is your feature request related to a problem? Please describe.
I am currently working on a Printer Application for PostScript printers. It should support all PostScript printers which simply work with CUPS due to having a manufacturer-supplied PPD file and the Snap also should contain all PPDs which are free software and were included with Linux distributions.
For that I have created libppd in cups-filters for handling collections of PPDs finding the correct one for a discovered printer and letting jobs output in PostScript format with the appropriate code snippets of the PPDs (especially of the user-settable options) inserted.
Now for handling a job I create a PAPPL filter which loads the PPD assigned to the printer, creates the list of PPD options and choices appropriate to the job's IPP attributes and the printer's defaults and then call an appropriate filter function of libcupsfilters.
To easily turn printer and job IPP attributes into the corresponding PPD option settings I have created the function ppdGetOptions() (in libppd, based on the get_options() function of CUPS' ippeveps.c) which takes the printer and job IPP attributes (a pointer to the whole structure) and the PPD file.I want to call theis function from my PAPPL filter but I cannot access the printer and job IPP attributes as the internal structures of pappl_printer_t and papple_job_t are not in the public API and there are also no accessor functions.
For the jobs one can also grab a single attribute when one knows its name, but I need the whole set of IPP job attributes to pass it on to the ppdGetOptions() function.
This is probably also useful for many other Printer Applications, especially non-raster ones.

Describe the solution you'd like
What I need are accessor functions which return a pointer to the job attributes and to the printer attributes, like for example:

ipp_t *pappleJobGetAttrs(pappl_job_t *job)
{
  return job->attrs;
}

ipp_t *papplePrinterGetAttrs(pappl_printer_t *printer)
{
  return printer->attrs;
}

Describe alternatives you've considered
Any solution with the existing API would be awkward, as one had to "translate" the PPD into the printer IPP attributes with each job and after that derive the possible job IPP attribute names out of the printer IPP attributes and after that poll the job's IPP attributes with each of the possible job attribute names using papplJobGetAttribute(). Adding the extra accessor functions to PAPPL is trivial and makes the implementation of the PostScript Printer Application easy.

As I am in the middle of creating the PostScript Printer Application and I am planning to create several other very similar ones (Foomatic for the Ghostscript built-in drivers and most other classic drivers, PCL XL, retro-fit of proprietary drivers, ...) I am very grateful if you could do this simple, trivial API addition quickly.

Web interface: One can set Borderless Media, but setting not displayed

Describe the bug
Under the media settings of a printer you have checkboxes for "Borderless". Checking it and saving the settings actually sets the printer to borderless (one can see in state file or when printing) but when opening the media settings the checkbox never appears checked, indpendent of the setting. The box should be checked when the media is already set to borderless. Also the Printing defaults should show the media not only with size and type but also with borderless status.

To Reproduce
Add a printer, must have capability of borderless printing (like the testpappl which comes with PAPPL). Enter media screen, set a media size and mark the borderless checkbox. Go to printing defaults. Only your selected size and media type is shown, no hint that you selcted borderless. Go back to media and you see that borderless is not checked, though it is active.

Expected behavior
When getting to the media settings again, the borderless checkbox should be checked when you have set borderless before. On Printing defaults the media dropdown should show whether the media is borderless.

IPP INFRA Proxy Support

Add support for functioning as an IPP INFRA Proxy, using both the PWG 5100.18 (INFRA) and PWG 5100.22 (SYSTEM) operations to register and accept print jobs via an INFRA server. Specific tasks:

  • Proxy threads for synchronizing printer and job state.
  • Web interface for adding/removing INFRA servers and doing any necessary authentication.
  • API for adding/removing INFRA servers w/auth info
  • API for querying INFRA servers
  • Adding of INFRA servers to the save/load functions
  • Secure storage for auth info

Segfault with hp-printer-app

Describe the bug
When I build hp-printer-app I get a segfault in the web interface after having created a printer and then try to open the media setup page by clicking the "Media" button.

To Reproduce

  • "git clone" both PAPPL and hp-printer-app
  • Build PAPPL by the usual ./configure; make
  • Build the hp-printer-app with the command line gcc -o hp-printer-app hp-printer-app.c <PAPPLDIR>/pappl/libpappl.a -ldl -lpthread -lcups -lavahi-common -lavahi-client -lgnutls -ljpeg -lpng16 -lz -lz -lusb-1.0 -lpam -I. -I<PAPPLDIR>pappl with <PAPPLEDIR> being the source directory of PAPPL.
  • Start hp-printer-app in server mode: ./hp-printer-app server
  • With the web interface create a printer with "HP LaserJet" driver, then click the "Media" button. The media configuration page does not open, the app has segfaulted.

Expected behavior
The media config page should show up.

System Information:

  • OS: Ubuntu Groovy 20.10
  • Browser Chromium Snap as it comes with Ubuntu 20.10
  • Version 85.0.4183.121
  • Printer HP OfficeJet Pro 8730, connected via both USB and network

Additional context
gdb backtrace of the core file

#0  0x0000557a8e60a7c6 in localize_keyword (bufsize=256, 
    buffer=0x7f2f6e863428 "US Legal", 
    keyword=0x557a8e60f02d "executive_7x10in", attrname=0x557a8e61d356 "media")
    at printer-webif.c:1341
#1  localize_keyword (attrname=0x557a8e61d356 "media", 
    keyword=0x557a8e60f02d "executive_7x10in", 
    buffer=0x7f2f6e863428 "US Legal", bufsize=256) at printer-webif.c:1274
#2  0x0000557a8e60d06d in media_chooser (media=0x7f2f6e862064, 
    name=0x7f2f6e863308 "ready0", title=<optimized out>, 
    driver_data=0x7f2f6e861100, client=0x557a90620e00) at printer-webif.c:1468
#3  _papplPrinterWebMedia (client=0x557a90620e00, printer=<optimized out>)
    at printer-webif.c:1084
#4  0x0000557a8e5fcfe1 in _papplClientProcessHTTP (
    client=client@entry=0x557a90620e00) at client.c:358
#5  0x0000557a8e5fd41a in _papplClientRun (client=0x557a90620e00)
    at client.c:623
#6  0x00007f2f708ed590 in start_thread (arg=0x7f2f6e866640)
    at pthread_create.c:463
#7  0x00007f2f704a2223 in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.