Till Kamppeter [Wed, 26 Jan 2022 02:09:37 +0000 (23:09 -0300)]
libppd: When parsing *.drv files for PPD collections, eliminate stderr
When generating PPD lists for PPD collections or extracting a PPD file
from a collection, *.drv files (CUPS has them in /usr/share/cups/drv)
can be parsed with the CUPS PPD compiler functions which got adopted
into libppd.
These functions are originally created for command line utilities to
handle *.drv files and PPD files and therefore they were rather
verbose on stderr in case there was an error in a file. As the PPD
collection handling functionality (ppd/pdd-collection.cxx) only
retro-fits existing *.drv files and does not serve for creating or
developing them, we simply re-direct stderr to /dev/null while
executing these functions to avoid any messages leaking into syslog or
the journal while running Printer Applications. This is much easier as
and less error-prone than introducing support for logging functions
into the obsolete and retro-fit-only *.drv handling function.
Mohit Verma [Tue, 25 Jan 2022 20:38:04 +0000 (02:08 +0530)]
libcupsfilters: Add input-page-ranges attribute to pdftopdf()
Pull request #444
The page-ranges option/attribute applies to the putput page stream going to the printer. If an 8-page input document is printed with number-up=2 one gets 4 sheets, with input pages 1+2, 3+4, 5+6, and 7+8, applying page-ranges=1,4 in addition will give a sheet with input pages 1+2 and 7+8. This way you can easily repeat sheets if they failed to print correctly on the first attempt to print the job.
There was no way to select for example page 1-3 and page 6 from the input and arrange it on 2 sheets with 1+2 and 3+6, for example if only these pages contain exercises which you have to solve. or content relevant for your exam. This is now solved by adding the new input-page-ranges attribute. If you now print with "input-page-ranges=1-3,6 number-up=2" you get exactly what you want (Issue #365).
Till Kamppeter [Fri, 21 Jan 2022 02:55:47 +0000 (23:55 -0300)]
libppd: When running driver/PPD generator executables, capture stderr
When generating PPD lists for PPD collections or extracting a PPD file
from a collection, CUPS driver/PPD generator executables (CUPS has
them in /usr/lib/cups/driver) can be called. The stderr output
(fortunately rare) of the driver/PPD generator executables did not get
captured and went directly to stderr (to syslog when the caller runs
as a system daemon).
This commit fixes it and re-directs the stderr output into the log
function, so that nothing is leaking into stderr any more.
In addition, more logging is added to the PipeCommand() and
ClosePipeCommand() functions.
Till Kamppeter [Sat, 15 Jan 2022 18:40:43 +0000 (15:40 -0300)]
libcupsfilters: Let PPD generator take default ColorModel from printer
Instead of selecting the "best" available color mode as default for
the PPD file generated from the response to the get-printer-attributes
IPP request we use the printer default according to the IPP attributes
(print-color-mode-default).
This way on can simply change the default on a network printer's web
interface or on a remote CUPS printer and clients using cups-browsed
or the "driverless" utility respect the change.
This solves https://github.com/OpenPrinting/cups/issues/277, together
with the changes done on CUPS for this issue.
Till Kamppeter [Sat, 15 Jan 2022 15:21:27 +0000 (12:21 -0300)]
libcupsfilters: In the PPD generator default to Color if available
The PPD generator takes the choices for the ColorModel option from the
print-color-mode-supported printer IPP attribute, using all listed
choices, including "Auto". It uses "Auto" as default choice if
present.
Michael Sweet in https://github.com/OpenPrinting/cups-filters/issues/426:
The PPD shouldn't have an "auto" option - generally speaking,
"auto" maps to "color" for color pages and "monochrome" for B&W
pages, which is something that the PDF RIP can automatically
detect and use the correct color/grayscale colorspace when "color"
is the default (i.e. optimize for the most common usage and don't
add a separate option to enable it).
Therefore we ignore "Auto" in the IPP attribute now and only add the
other choices, setting color as default if a color choice is present,
monochrome/gray otherwise.
This should fix the color output problem mentioned in
https://github.com/OpenPrinting/cups-filters/issues/426
TinyTrebuchet [Sat, 15 Jan 2022 14:35:32 +0000 (20:05 +0530)]
Braille: In vectortopdf check inkscape version to call inkscape with the correct command line
From version 1.0.x on, Inkscape does not support the '-A' command line flag any more. Now we check the inkscape version and call inkscape always with the correct command line.
chandresh soni [Thu, 13 Jan 2022 20:07:18 +0000 (01:37 +0530)]
libcupsfilters: Close files on file copy error in filter functions
Some filter functions do not close the input file when it comes to an error opening a temporary file to copy the input into. This causes a memory leak in continuously running callers, like Printer Applications.
Till Kamppeter [Thu, 13 Jan 2022 17:39:09 +0000 (14:39 -0300)]
libcupsfilters: In ieee1284NormalizeMakeAndModel() do not remove extra after ()
If a PPD's NickName has extra info in parentheses after the model name
we have thrown away any further text after the parentheses. As
PPD-retro-fitting Printer Applications add the PPD's language (for
example "(en)") to the end of the NickName and then call
ieee1284NormalizeMakeAndModel() to generate the unique driver name,
this language info extension gets thrown away and the unique driver
name identical for all language versions of the same printer's PPD,
making the entries clobbering each other leaving only the first in the
alphabet, which is often German ("de") and rarely English.
Now we do not remove any part of the input string's extra info to
remedy this problem.
Till Kamppeter [Tue, 4 Jan 2022 20:07:50 +0000 (17:07 -0300)]
libcupsfilters: In imagetoraster() fixed crash with SGray
As the SGray color space was not mentioned in the switch for selecting
the raster line formatting function, a 3-channel color formatting
function was selected instead of the 1-channel grayscale one, leading
to an overrun of the input pixel line, causing a crash.
This is fixed now by also mentioning the 3 standard color spaces for
driverless printing, SGray, SRGB, and AdobeRGB explicily (where for
the latter 2 the selection already worked as they are 3-channel color
options).
Till Kamppeter [Sun, 2 Jan 2022 03:49:32 +0000 (00:49 -0300)]
libcupsfilters: Fixed pdftopdf() for asymmetric margins
On some printers the left unprintable margin does not equal the right
one and/or the top margin does not equal the bottom one. pdftopdf()
did not always place the input pages correctly on the output sheets,
having de-centered printouts in crop-to-fit mode
("print-scaling=none") or missing content at the borders in
scale-to-fit mode ("print-scaling=fit").
Probably pdftopdf() did not get (well) tested with such printers.
This commit addresses these issues:
- In crop-to-fit mode we set the margins of the output page to
all-zero befor starting all the math. This way we assure pages get
centered and the correct (asymmetric) crop is done by the following
filters (driver) or the printer (by simply ignoring the pixels
falling into the margins). Alao for N-up here the input pages are
filling exactly the halves, quarters, ... of the sheet, allowing
easy mounting of booklets. pdftopdf() is producing an output PDF
with pages of the size of the output sheet (not of its printable
area) anyway and it does not need to passon pages where the
unprintable margins are actually white.
- Set the auto-fit bit for crop-to-fill mode ("print-scaling=fill"),
to assure that the pages cropped to the aspect ratio of the
printable area of the output page are correctly scaled into that
area (this got probably accidentally dropped in an earlier commit).
- Corrected the margin offsets at the coordinate origin for N-up
printing in Landscape orientation (2-up, 6-up, 8-up, ...), so that
they work with asymmetric margins.
- Let the crop() method for a PDF page not create a page smaller than
the destination page. When "cropping" a smaller input page, set its
crop box so that it gets centered on the output page. This makes the
input pages always printed in original size in crop mode, even if
they are smaller than the output page.
Till Kamppeter [Thu, 30 Dec 2021 14:28:06 +0000 (11:28 -0300)]
libcupsfilters: Let pdftopdf() not send NULL to log function
The variable holding the value of FINAL_CONTENT_TYPE is NULL when the
environment variable is not set. At one place the variable value gets
logged using the log function. Do not send NULL here, to avoid a crash
of the log function.
Till Kamppeter [Thu, 30 Dec 2021 02:49:15 +0000 (23:49 -0300)]
libcupsfilters: Fix orientation-requested = 0 in pdftopdf()
CUPS often adds "orientation-requested=0" to the options in the
filter/backend command line, meaning automatic selection. pdftopdf()
did not support this value and therefore did not do the correct
settings making margins of rotated landscape pages not be done
correctly.
Till Kamppeter [Thu, 30 Dec 2021 02:33:53 +0000 (23:33 -0300)]
libcupsfilters: Let cupsRasterPrepareHeader() create complete header
The cupsRasterPrepareHeader() function creates a CUPS/PWG Raster
header for Raster output based on the printer and job properties
supplied to the calling filter functions.
This commit fixes the header produced by this function to be complete
and consistent so that it can be used for actual Raster output. It
adds the following missing pieces:
- Find correct dimensions and margins for the page size requested by
the job.
- After having found page dimensions, margins, color space, color
depth, and resolution, set all fields of the header which depend on
this to the correct values, to assure that the resulting header is
consistent.
Also did some fixes in cupsRasterParseIPPOptions()
- Create the empty header with all-zero before starting, to have
everything well-defined.
- Fixed setting for requested orientation, to correctly handle 0 as
input or wrong input values.
Till Kamppeter [Thu, 30 Dec 2021 02:12:00 +0000 (23:12 -0300)]
libcupsfilters: Fix resolver functions for DNS-SD-based URIs
CUPS and cups-browsed use DNS-SD-service-name-based URIs, so that the
printer URIs are robust against changes of network details, for
example of the port, if Printer Applications on a system come up in
different order at every boot.
To be able to access the printer these URIs have to get resolved,
which means to get converted into standard IPP URIs. This is done by
two functions with their source being in cupsfilters/ipp.c.
Unfortunately both functions have a bug and in this commit we fix
these bugs to make the functions correctly working in all cases.
1. resolve_uri()
This function calls cupsBackendDeviceURI() of libcups which resolves
device URIs for the CUPS backends. As it is designed for only using in
CUPS backends it needs some workarounds to make it usuable as
universal library function and make it work in a wide range of system
environments.
One workaround was already applied from the beginning on, re-directing
stderr into the Nirwana, to avoid messages to stderr.
Another is needed and now added: We need to unset the DEVICE_URI
environment variable as the function searches for the device URI to
resolve there at first and not as argc[0]. Otherwise, if we are
running under CUPS, in a backend, we get the print queue's device URI
resolved and not the one which we supply.
We save and restore the value of DEVICE_URI to keep the impact as low
as possible.
2. ippfind_based_uri_converter()
In this function the ippfind utility is called in a fork and the
foreground (parent process) is getting ippfind's stdout through a
pipe. The main process is picking up the data to use it for resolving
the given URI. Here the parent process has unnecessarily: "dup"ed the
read end of the pipe to stdin, and then read the lines from
stdin. This prevents the calling program to use stdin by itself, for
example to receive print job data.
Now this is fixed by directly reading from the read end of the pipe.
Till Kamppeter [Thu, 30 Dec 2021 01:52:36 +0000 (22:52 -0300)]
implicitclass: Get printer info via IPP request and not via PPD
If we create a printer cluster with cups-browsed a PPD file covering
the capabilities of all member printers is genererated, which
especially does not represent the capabilities of a single member
printer which gets selected to print a particular job. It also does
not contain the infor about color spaces and color depths which can
vary from printer top printer.
For the implicitclass backend to have the exact information about the
destination printer so that it can call the filters correctly we now
poll this information directly from the printer, using a
get-printer-attributes IPP request. With this we get exact paper sizes
and margins and also the color spaces and color depth which are
especially needed if the printer gets the job as raster data
(Apple/PWG Raster, PCLm).
We completely ignore the print queue's PPD file here and so the
filters get used PPD-less only based on the printer's IPP attributes.
Till Kamppeter [Fri, 24 Dec 2021 01:52:20 +0000 (22:52 -0300)]
libcupsfilters: PCLm support in cupsRasterPrepareHeader()
The cupsRasterPrepareHeader() function only supported Apple/PWG/CUPS
Raster but not PCLm, leading to PCLm output often being broken,
especially when using the univeral() filter function.
Till Kamppeter [Wed, 22 Dec 2021 22:57:32 +0000 (19:57 -0300)]
cups-browsed: Updated naming of locally created print queues
Naming of local queues created by cups-browsed is now matched to CUPS'
current naming of temporary queues (no leading or trailing
underscores), to avoid duplicates in print dialogs which support CUPS'
temporary queues.
Till Kamppeter [Wed, 22 Dec 2021 22:17:53 +0000 (19:17 -0300)]
libcupsfilters: Removed pdftoippprinter.[ch]
As we have filter functions replacing practically all filters and can
call one or another external CUPS filter executable (driver) or even
backends via filterExternalCUPS(), we do not need any more the
apply_filters() API function to execute chains of external CUPS filter
executables. Therefore we remove this function.
Till Kamppeter [Wed, 22 Dec 2021 20:08:04 +0000 (17:08 -0300)]
cups-browsed, implicitclass: Let the implicitclass backend use filter functions
Let the implicitclass backend use filter functions instead of calling
filter executables, to make use with the latest development of
cups-filters.
- We use the universal() filter function, as this automatically
generates and executes a filter chain converting from a given input
to a given output format.
- In cupsfilters/filter.c we create functions to simplify adding the
FD_CLOEXEC and O_NONBLOCK (aka O_NDELAY) flags without losing any
already set flags.
- In the filterChain() filter function we make sure that the file
descriptors have the close-on-exec flag set, to assure that there
are no file descriptors left open or accessible by the executables
called by and of the filter functions in the chain.
- In filterExternalCUPS() we set O_NONBLOCK for stderr, back channel
and side channel.
- In filterChain(), when closing unneeded file descriptors, we do not
close FD 0 and FD 1 (stdin and stdout) as accidentally closing stdin
or stdout can break the data stream connection to/from a backend or
filter called by filterExternalCUPS() in the filter chain. Also
check each file descriptor separately for this, instead of only
checking one file descriptor and then close a group of file
descriptors.
- cups-browsed now removes the unneeded "*cupsFilter:..." lines from the
PPD for the local queue generated by cups-browsed, to assure that the
inserted line for application/vnd.cups-pdf gets used.
Till Kamppeter [Tue, 7 Dec 2021 21:58:54 +0000 (18:58 -0300)]
libcupsfilters: Added filterTee() filter function for debugging
This filter function is mainly for debugging. it resembles the "tee"
utility, passing through the data unfiltered and copying it to a
file. The file name is simply given as parameter. This makes using the
function easy (add it as item of a filter chain called via
filterChain()) and can even be used more than once in the same filter
chain (using different file names).
In case of write error to the copy file, copying is stopped but the
rest of the job is passed on to the next filter. If NULL is supplied
as file name, the data is simply passed through without getting
copied.
Till Kamppeter [Tue, 7 Dec 2021 01:44:45 +0000 (22:44 -0300)]
libcupsfilters: Fixed env variable handling in filterExternalCUPS()
- Do not forward blank environment variables (name is empty string)
into the environment of he called filter/backend.
- Do not match a given env variable name with a part of an existing
name (like CUPS_SERVER with CUPS_SERVERBIN). This way CUPS_SERVER in
the environment of the caller overwrote CUPS_SERVERBIN in the
environment of the filter to be called.
Till Kamppeter [Sat, 4 Dec 2021 23:40:53 +0000 (20:40 -0300)]
libcupsfilters: In universal() do not use pdftopdf() on vnd.cups-pdf input
application/pdf is raw, device-independent PDF, whereas
application/vnd.cups-pdf is PDF prepared for the output device,
usually with the page sizes and scalings adjusted to the output
printer and page management options, like N-up, applied.
The pdftopdf() filter function is to get from the former to the
latter. If we have input data which already has pdftopdf() applied, we
set the input format MIME type to application/vnd.cups-pdf to tell
that pdftopdf() is already done. In this case universal() should not
call pdftopdf() again.
This commit corrects the call of pdftopdf(), to be suppressed if the
input format is application/vnd.cups-pdf. On any other input format
which is going through PDF on the way to get converted into the output
format we call pdftopdf().
RFC7472 requires that 'ipps' must be used over HTTPS, but driverless
does not enforce encryption and will use insecure connection by
default. This makes it unusable with a printer that expects secure
connection only on 'ipps' port.
Till Kamppeter [Fri, 26 Nov 2021 12:53:43 +0000 (13:53 +0100)]
libppd: When running dynamic PPD generators wait for the process to finish
The PPD collection functions come from the cups-driverd daemon helper.
As cups-driverd did not run permanently (like cupsd or a Printer
Application) but was started for each request no sophisticated
clean-up was performed after responding to the request.
This fact was overlooked at some points when the functions were
transferred to libppd and supposed to be directly called by
permanently running Printer Applications. Here especially forked
processes for running dynamic PPD generator executables (the ones CUPS
uses in /usr/lib/cups/driver) were not waited for in the end. This
made them often dandling around as zombie processes and these could
accumulate during the life of a Printer Application process. See
https://github.com/OpenPrinting/cups-filters/issues/430.
This is fixed now by adding an appropriate function.
To avoid zombie processes dangling around during the life of a Printer
Application
Till Kamppeter [Thu, 25 Nov 2021 18:11:21 +0000 (19:11 +0100)]
libcupsfilters: In universal() error on invalis input/output formats
If invalid input and/or output formats get provided as parameters, the
universal() flter function simply silently chooses valid formats
instead of erroring out. This is fixed with this commit.
Till Kamppeter [Thu, 25 Nov 2021 16:25:48 +0000 (17:25 +0100)]
libcupsfilters: In pdftopdf() set a default for "print-scaling"
If no setting for "print-scaling" is provided via IPP attribute pr
command line option there is no default valur for it and we get
undefined behavior and also a scary "should never happen" message in
the log.
Now we check after parsing the appropriate IPP attributes and command
line options whether a setting was provided. If not, we use "auto".
Till Kamppeter [Thu, 25 Nov 2021 15:57:12 +0000 (16:57 +0100)]
libcupsfilters: In pdftops() simplify feeding data into post-processing
In post-processing we stop assigning the file descriptorof the input
pipe to stdin and then read the data from stdin but instead, read the
data directly from stdin.
Without this improvement in some cases, especially when we do not have
a PPD file, we are not able to get the output data of the previous
step (Poppler's pdftops or Ghostscript to turn PDF to PostScript, and
the really strange is that this only happens when we call pdftops()
from the universal() filter function).
Till Kamppeter [Thu, 25 Nov 2021 13:47:07 +0000 (14:47 +0100)]
libcupsfilters: In pdftops() call pstops() only if we have a PPD
After doing the actual PDF-to-PostScript conversion and afterwards
sometimes post-processing to work around PostScript interpreter bugs
in some PostScript printers we call the pstops() filter function to
insert the printer-specific PostScript instructions for the option
settings into the PostScript output data stream.
If there is no PPD file pstops() has nothing to do, and therefore we
simply skip it now. In addition, in absence of a PPD, some standard
PostScript code for standard options is inserted in the postprocessing
step.
Till Kamppeter [Wed, 24 Nov 2021 14:51:46 +0000 (15:51 +0100)]
libcupsfilters: in pdftops() simplified feeding data into pstops()
In the fork for running the pstops() filter function do notdo a file
descriptor redirection detour via stdin. pstops() accepts an input
file descriptor directly.
This made the pstops() filter not getting the job data when pdftops()
used Poppler's pdftops utility as PostScript interpreter when
pdftops() is called by the universal() filter function.
Till Kamppeter [Fri, 19 Nov 2021 21:22:27 +0000 (22:22 +0100)]
libcupsfilters: In universal() use Ghostscript for PDF-to-Raster
As Ghostscript is more optimized for print output we use now the
Ghostscript-based ghostscript() filter function to convert PDF into
PWG/CUPS Raster and not the Poppler-based pdftoraster() any more.
Later on we will add conditional compiling to use Poppler in a
Ghostscript-less build of cups-filters.
Till Kamppeter [Wed, 17 Nov 2021 19:44:57 +0000 (20:44 +0100)]
libcupsfilters: Let universal() pass FINAL_CONTENT_TYPE to pdftopdf()
pdftopdf() uses the FINAL_CONTENT_TYPE environment variable to
determine whether to log the printed pages and for other things, so
the universal() filter function should pass it through.
Till Kamppeter [Wed, 17 Nov 2021 18:42:32 +0000 (19:42 +0100)]
libcupsfilters: Fixed several bugs and did some clean-up in pdftopdf()
- Tested and corrected processing according to the "print-scaling" IPP
attribute, especially an A4 document on A4 destination page size got
shrinked by the width of the unprintable margins.
- Also tested and corrected N-up printing with all settings for
"print-scaling" and with documents containing pages of different
sizes and different orientations.
- On multi-page documents check each page (not only the first page) if
it is larger than the destination page size and with at least one
oversized page apply scale-to-fit/fill to all pages (if
"print-scaling"is "auto" or "auto-fit").
- On multi-page documents check each page individually whether it
needs to get rotated when determining how it should get cropped.
- Make sure that the page->crop() and page->is_landscape() do not
modify the /Rotate keys in the PDF. Save the key and restore it
before returning.
- Cleaned up the code for processing the pages, especially removed
code which never gets called, with any of the possible settings for
"print-scaling".
- For options use the options/num_options data structure which
contains both command line options and IPP attributes.
- Added more log messages, especially for the "print-scaling" and
"ipp-attribute-fidelity" IPP attributes.
Till Kamppeter [Mon, 15 Nov 2021 00:23:20 +0000 (01:23 +0100)]
MIME rules: Added application/vnd.cups-pdf-banner rule for universal filter
bannertopdf() is added to the universal() filter function now, so we
can tell CUPS that the universal CUPS filter accepts banner/test page
instruction files.
Till Kamppeter [Sun, 14 Nov 2021 23:38:31 +0000 (00:38 +0100)]
libcupsfilters: Let filterChain() pass through data on empty chain
If the supplied filter chain does not contain any filter or only
filter entries with the filter function set to NULL, we pass the data
through unchanged now, we simply not applying any filters.
This can happen when the universal() filter function is called iwth
the same MIME type for the input and for the output format
supplied. In such a case we simply want the data passed through.
Till Kamppeter [Wed, 10 Nov 2021 19:20:47 +0000 (20:20 +0100)]
driverless: Do not execute if NO_DRIVERLESS_PPDS env variable is set
If we have a Printer Application which wants to make available all the
CUPS drivers installed on the system (in the directories where CUPOS
would look for them), we have on many systems also the driverless
utility of cups-filters installed, linked into /usr/lib/cups/backend,
to discover driverless IPP printers, and in /usr/lib/cups/driver, to
auto-generate CUPS PPD files for them.
The Printer Application is supposed to make printers available which
use the installed drivers but does not need to make available
driverless IPP printers. Therefore we do not want that the Printer
Application executes the driverless utility to discover printers and
list possible PPD files for them. But we also do not want to remove
the driverless utility.
Therefore we add in this commit a facility to de-activate the
driverless utility by the presence of the NO_DRIVERLESS_PPDS
environment variable. If the variable is defined, the utility exits
right away when it gets called, not doing anything. So a Printer
Application looking for printers and PPD files by running CUPS
backends and dynamich PPD generator executables for CUPS in their
usual places in the file system can set the variable and a perhaps
installed driverless utility will simply do nothing and so the Printer
Application will not list all driverless IPP as supported with a
"driverless" driver choice.
The driverless utility is only thought out as a retro-fit of
driverless printers into classic printer setup tools (and as debugging
tool) but not for PPD-retro-fitting Printer Applications.
Till Kamppeter [Tue, 9 Nov 2021 23:35:20 +0000 (00:35 +0100)]
Build system: ENABLE_... conditionals in Makefile.am only for file inclusion
In makefile.am use "if ENABLE_..." conditionals only to decide which
files get included in general "make" and "make install" processes, not
for compilation rules. This way single filters can be built by "make
NAME" regardless whether appropriate "--enable-..." arguments got
supplied to "./configure".
Now we can do "make pstops" and make "make rastertopwg" without
appropriate arguments for "./configure".
Till Kamppeter [Mon, 8 Nov 2021 20:16:26 +0000 (21:16 +0100)]
Build system: Updated after addition of the universal() filter function
Now, with the cUPS filters all converted to filter functions the
filter executables which are installed into /usr/lib/cups/filter are
only small code stubs which convert the CUPS filter command line
arguments into the filter data and parameters for calling the filter
function and then calling the filter function itself.
With the addition of the universal() filter function, which
automatically converts any supported input format into any supported
output format by automatically creating an appropriate filter chain
there are two ways for interfacing the filter functions with CUPS now:
1. One individual executable for each filter functions: This makes
cups-filters behave as before. CUPS creates chains of the filters
needed for converting the job data to the required output format.
2. A single universal filter executable: This internally chains the
filter functions for getting the input data into the desired output
format. This is less resource-consuming as less external executables
have to be called by CUPS for processing each print job.
cups-filters can be built with either individual filter executables or
the universal filter executable, or also with both. This is controlled
by the "./configure" script with the "--enable-universal-cups-filter"
and "--enable-individual-cups-filters" command line arguments. Default
is to build only the universal filter executable. MIME conversion
rules are installed appropriate to the installed CUPS filter
executables.
Also done:
- Re-arranged the MIME conversion rules for using the classic,
individual CUPS filter executables and for using the universal
filter executable
- Require the QPDF version 10.3.2 and so removed the "./configure"
switch for QPDF not supporting PCLm
- Require CUPS 2.2.2 or newer and removed the "./configure" switch for
using urftopdf instead of Apple Raster support of libcups.
pranshukharkwal [Sun, 7 Nov 2021 17:24:54 +0000 (22:54 +0530)]
libcupsfilters, universal: Add a universal filter function to replace chains of individual filters
To execute a print job CUPS usually has to turn the input data format into PDF, ptocess the PDF with page management functions, like N-up, only even/odd pages, page selection, scaling, ..., and then turn the PDF into a data format understood by the printer. For this it calls a chain of several filters in most cases which causes an overhead of starting individual processes and data input/output.
To reduce this overhead we have here a single, universal filter function which calls a chain of one or more suitable individual filter functions using the filterChain() filter function. It take the input and output format MIME types as parameters and automatically determines a suitable combination of filters to do the desired conversion.
For use with CUPS, to have (except printer drivers) only one single filter for everything, we have also a filter executable as for the individual filters and a MIME conversion rules file to tell CUPS that it converts a wide range of input formats into a wide range of output formats. To not require n * m lines in the conversion rule file to support n input and m output formats, we use an auxiliary input MIME type to reduce the number of lines to n + m, and to allow easy addition and modification of formats as each format is only mentioned once in the file.
This universal filter function is the GSoC 2021 project of Pranshu Kharkwal (Pull Request #421, https://gist.github.com/pranshukharkwal/9413499a6744049ef549159948392023). Thanks a lot!
Till Kamppeter [Sat, 6 Nov 2021 16:18:24 +0000 (17:18 +0100)]
libcupsfilters: In ieee1284NormalizeMakeAndModel() remove "series" from model
We remove "series" from the model names when normalizing now, so we
also get a match if the printer list entry has "series" but the search
term not, or vice-versa (when both printer list enries and search
terms are normalized).
Till Kamppeter [Mon, 1 Nov 2021 22:25:52 +0000 (23:25 +0100)]
libcupsfilters: In ieee1284NormalizeMakeAndModel() also consider " - " as separator
Before, ieee1284NormalizeMakeAndModel() only considered ',', ';', and
'(' as separator between printer model name and extra info (driver,
version, language, ...). Now we also consider " - " (isolated dash) as
such a separator.
Till Kamppeter [Fri, 29 Oct 2021 13:03:02 +0000 (15:03 +0200)]
libcupsfilters: In bannertopdf() get printer name from filter data
In the bannertopdf() filter function get the print queue name from the
filter data and not from the PRINTER environment variable, as the
filter data is the standard source for this item in a filter function.
Till Kamppeter [Fri, 29 Oct 2021 09:04:22 +0000 (11:04 +0200)]
bannertopdf() templates: Adeed instructions to PDF templates
With the change on the bannertopdf() filter function of the previous
commit the template PDF files can get directly fed into bannertopdf()
and the instructions for adding printer- and job-specific text can be
embedded in the templates.
This commit adds the appropriate instructions to each template file,
to not break PDF integrity to the end. So one can even modify the
instructions without breaking the template itself.
If feeding banner instruction files into bannertopdf() as before, the
embedded instructions get ignored.
Also added files with only the instructions, the data/*-append.txt
files. They are not actually used but only FYI.
Till Kamppeter [Fri, 29 Oct 2021 07:50:15 +0000 (09:50 +0200)]
Improved bannertopdf() filter function
Main reason of the improvements is to make the bannertopdf() filter function
more suitable for Printer Applications, conserving its functionality for
CUPS.
Changes:
- Instead of a pair of an instruction file
(application/vnd.cups-pdf-banner) and a template PDF file we can
only use the template PDF file now, sending it as input file to the
filter function instead of the instruction file. The instruction
file content can be added to the PDF file as PDF comments,
preferrably at the end. If no instructions are added to the template
file, default instructions are used.
- Job-/Printer-related text added to a template file without PDF form
(according to "Show" instruction) is now cleaned up, not showing lines
at all for fields for which no content is supplied, instead of showing
"(null)" or nothing as content.
- Page dimensions are now also shown in centimeters and not only in
inches.
Till Kamppeter [Tue, 26 Oct 2021 17:02:59 +0000 (19:02 +0200)]
libppd: Merged libppdc into libppd, *.drv support for PPD collections
CUPS PPD compiler (ppdc) was mainly ported into cups-filters to get
driver information file (*.drv) support for PPD file collections, so
that it gets easier to retro-fit CUPS drivers into Printer
Applications if the drivers provide their PPD files as a driver
information file.
In a first approach the ppdc functionality simply got added by an
additional shared library (libppdc), but this would cause circular
dependencies between libppdc and libppd. Therefore we simply merge the
two into one library.
In addition, all PPD legacy support is in a single library now.
Also note that the ppdc functions are written in C++, so you need to
declare a program which uses them as C++ (give it a *.cxx or *.cpp and
not the simple *.c file name extension), even if the program itself is
written in simple C.
The functions for handling PPD collections nw also take into account
any driver information file (*.drv) in the directories supplied to
them, in addition to the already supported static PPD files, PPD file
tarballs, and PPD-generating executables, both for enumerating
available PPDs/drivers and for loading the actual PPD files.
Till Kamppeter [Mon, 25 Oct 2021 23:02:28 +0000 (01:02 +0200)]
Ported CUPS' PPD compiler into cups-filters
Together with PPD files the PPD compiler, which generates PPD files
from driver information files (*.drv) is deprecated in CUPS and will
get removed in CUPS 3.x.
CUPS 3.x and later (and also earlier CUPS versions when sandboxed,
like in a Snap) do not support classic CUPS drivers any more and need
Printer Applications (emulations of driverless IPP printers) for
non-driverless printers.
For retro-fitting classic CUPS drivers, consisting of PPD files, CUPS
filters, and CUPS backends, into Printer Applications without needing
to rewrite the driver (which can be old and the printer it supports
not at hand for testing) we wrap the driver into the Printer
Application without changing the driver itself (usually with the
pappl-retrofit library). Therefore we need to be able to handle PPD
files and especially also the driver information files (*.drv) which
some drivers use to generate their PPD files on-the-fly. Therefore we
conserve CUPS' PPD compiler here to be able to pre-build the PPDs (or
even also generate them on-the-fly) when retro-fitting the drivers
into Printer Applications.
In contrary to recent CUPS we provide the PPD compiler code as a
shared library (libppdc), so that other projects, like pappl-retrofit
can use it.
Note that this is only for retro-fitting existing printer drivers.
This should not motivate you to create new printer drivers using PPD
files or driver information files. Therefore we will also not add new
features to this code or to the corresponding file formats.
Till Kamppeter [Sun, 24 Oct 2021 09:07:28 +0000 (11:07 +0200)]
libcupsfilters: In texttopdf() did redirrection of stdout to outputfd
The texttopdf() filter function was missing the redirection of stdout
to the output file descriptor of the function call, outputfd.
On error of parsing the charset configuration file and loading the
fonts exit(1) was called which would kill the caller in a filter
function. This is corrected now, too.
The files filter/pdfutils.c and filter/pdfutils.h got moved into
libcupsfilters, for the texttopdf() filter function. But they did not
get removed from the filter/ directory and the build rules for
filter/test_pdf[12].c not updated to use the pdfutils files of the
library now.
Till Kamppeter [Fri, 22 Oct 2021 19:20:52 +0000 (21:20 +0200)]
libcupsfilters: In ieee1284NormalizeMakeAndModel() fix parsing device IDs
Some IEEE-1284 device IDs have spaces before and after the
manufacturer and model names. These need to be removed when generating
make-and-model strings for display, sorting, ... THis especially leads
to duplicate manufacturer names (extra mention of manufacturer in
model name) not being recognized and removed.
Till Kamppeter [Wed, 20 Oct 2021 14:51:15 +0000 (16:51 +0200)]
libcupsfilters: In pwgtoraster() with PPD do not modify header via IPP options
In the pwgtoraster() filter function, if we have a PPD file, we do not
call cupsRasterParseIPPOptions() as it sets the Raster header entries
solely by the names and choice names of the IPP attributes and command
line options, regardless of what the PPD supports. This broke some
jobs.
If we have a PPD, we need to convert IPP attributes into proper PPD
options before calling the filter functions (what is done by
libpappl-retrofit for example).
Till Kamppeter [Tue, 19 Oct 2021 10:14:11 +0000 (12:14 +0200)]
libppd: Added "FXOutputMode" of Fuji Xerox to auto-mapping
Fuji Xerox has several high-end printers which take jobs in PDF from
the pre-driverless-IPP era, for which they had the "fxlinuxprint"
driver. The PPD contains an "FXOutputMode" option with an odd
"Quality2" choice for high quality. Now it is solved by an explicit
treatment of this option.
Till Kamppeter [Mon, 18 Oct 2021 21:38:37 +0000 (23:38 +0200)]
libcupsfilters: Let filterExternalCUPS() return 1 if filter gets a signal
If the CUPS filter or backend called by the filterExternalCUPS()
filter function stops on a signal (like for example signal 11,
segmentation fault) filterExternalCUPS() returns 1 now and not a value
> 256. Otherwise filterChain() will not see the failure (exit() only
passes on the last byte of its argument as exit code) and returns 0
for success, making a job with a crashed filter appear as succeeded.
Till Kamppeter [Mon, 18 Oct 2021 20:33:46 +0000 (22:33 +0200)]
libcupsfilters: Allow filter without path in filterExternalCUPS()
The filterExternalCUPS() function now also works if the filter (or
backend) is specified without absolute path. In this case the
CUPS_SERVERBIN environment variable (does not matter whether it was
set in the actual environment or in the parameters of
filterExternalCUPS()) is used to locate the filter or backend, using
the /filter or /backend subdirectory of the directory specified by
CUPS_SERVERBIN.
In addition, this directory is also added to the beginning of PATH, as
CUPS does, so that filters/backends can find auxiliary programs (or
other filters if they are a wrapper) in the same directory where they
themselves are located.
Till Kamppeter [Mon, 18 Oct 2021 20:26:51 +0000 (22:26 +0200)]
Sample PPDs: Useful "*Product:" name in the PCL-XL PPDs
The PCL-XL PPDs, pxlmono.ppd and pxlcolor.ppd, the product name was
"GPL Ghostscript" which could make make printer setup tools list these
PPDs with this name which does not say anything about the PPD, and
even consider the second one as duplicate of the first one (both
libpappl-retrofit and pyppd did this before they received their most
recent improvements).
Now they names are more useful and the PPDs always listed correctly.
Till Kamppeter [Tue, 12 Oct 2021 11:33:26 +0000 (13:33 +0200)]
libcupsfilters: Make cupsRasterParseIPPOptions() work correctly with PPDs
cupsRasterParseIPPOptions() interprets job options/IPP attributes and
their settings just bei their names. This works well when the
destination printer is not described by a PPD file.
If there is a PPD file, their can be weird option and choice names
which do not tell what they are good for, giving wrong
impressions. Only the PostScript or PJL code assigned to the choices
in the PPD file tells what they actually are supposed to do.
A good example for that is the "Resolution" option of Gutenprint. As
the developers of Gutenprint do not want to solely and directly set
the print resolution with this option (as was Adobe's idea for it),
and instead, do more things with it, as having an "Automatic" choice
or variants of the same resolution (for example different dithering
algorithms), but PPD standards require the choices to be "XXXxYYYdpi"
without exceptions, they come with names like "601x600dpi" for the
variants and the PPD's embedded PostScript code contains the actual
resolution.
To avoid that cupsRasterParseIPPOptions() mis-interprets such weird
PPD options, we check whether we are using a PPD (fortunately, we
receive the complete filter data now, in the era of filter functions)
and if so we refrain from parsing options which are in the PPD. Only
if set_defaults = 1 is set, we use them but via a call of
ppdRasterInterpretPPD() and not interpreting them by ourselves
option/choice-name-only.
Now the Gutenprint Printer Application works again.
Till Kamppeter [Tue, 12 Oct 2021 09:23:02 +0000 (11:23 +0200)]
libcupsfilters: Clean up "Kodak" manufacturer name
Some Kodak printers/PPD files report "Eastman Kodak Company", others
simply "Kodak" as manufacturer name. Let the
ieee1284NormalizeMakeAndModel() function use simply "Kodak" here.
Till Kamppeter [Wed, 22 Sep 2021 10:24:24 +0000 (12:24 +0200)]
libppd: Improved caching of PPD's page sizes and custom page size limits
1. If an PPD page size has non-standard dimensions, pwgMediaForSize()
returns "custom_WIDTHxHEIGHTuu_WIDTHxHEIGHTuu" and not NULL, while we
assume that we would get NULL in such a case. So consider "custom_..."
PWG page size names also as a PWG size not having been found. This
gives PWG page size nmaes of "pp_lowerppd_WIDTHxHEIGHTuu" style, much
more useful and the page size not being skipped by PAPPL's web
interface.
2. If the PPD defines a too high demension (something like ~30 m is
enough) for the maximum allowed custom page size, the generated PWG
page size name ("custom_max_WIDTHxHEIGHTuu") contains negative numbers
due to an integer overflow. If this happens, we sanitize the string
now replacing these negative numbers by a high integer value (10000
inches or 100000 mm). This PWG size name is used by PAPPL's web
interface to know about the allowed dimensions for a custom page
size. With a negative value the web interface inserts 0, making the
max dimension smaller than the min and with this clicks on the "Save
Changes" button on the "Media" web interface page of PAPPL are
silently ignored.
Add missing line continuation character in libcupsfilters-la_LIBADD
stanza. This fixes "make[2]: lm: No such file or directory" errors while
building.
Move fontembed library before cupsfilters library, this fixes
"/usr/bin/ld: cannot find -lfontembed" errors during install. This may
just be a workaround for dependency resolving issues elsewhere.
Till Kamppeter [Sun, 19 Sep 2021 21:39:27 +0000 (23:39 +0200)]
libppd: Fixed PPD URIs when generating dynamic PPDs
The PPD URIs of the PPD collection handling of libppd are not
identical with the PPD URIs of CUPS and so not identical with the PPD
URIs used by the dynamic PPD generator executables (the ones which are
in /usr/lib/cups/driver/ for CUPS). The difference is in the scheme,
the part before the colon. The schemes for the dynamic PPD generator
did not get extracted correctly. Most dynamic PPD generatores do not
use the scheme internally and therefore work also with the scheme
corrupted, like pyppd or HPLIP, but Gutenprint does not, as it checks
the version by the scheme,
This commit fixes the extraction of the scheme and so all dynamic PPD
generators should work now.
Till Kamppeter [Sun, 19 Sep 2021 17:32:33 +0000 (19:32 +0200)]
libcupsfilters: Let colord_get_profile_for_device_id() not return empty file name
If the function colord_get_profile_for_device_id() returns an empty
file name, the color generates an error message in the CUPS
error_log. Some print dialogs report every log message of level error
to the user even if the job got correctly printed.
Till Kamppeter [Wed, 15 Sep 2021 18:51:02 +0000 (20:51 +0200)]
libppd: In IPP-attr-to-PPD-option auto mapper consider "ColorMode" also with prefix
This way we also cover "cupsColorMode" for example which appears in
auto-generated PPDs for driverless IPP printers (in case we cannot
print directly to the printer but only have access via a CUPS queue).
Till Kamppeter [Fri, 3 Sep 2021 21:21:26 +0000 (23:21 +0200)]
libcupsfilters: In ghostscript() pass on LD_LIBRARY_PATH to Ghostscript
In unusual environments (are they still actually unusual?) like Snaps
or other sandboxed packages libraries are not always in standard
locations and the LD_LIBRARY_PATH environment variable tells about the
extra locations then. So when we continue to block out the caller's
environment variables when we call Ghostscript, we have to pass on at
least LD_LIBRARY_PATH.