pkgmimedir = $(CUPS_DATADIR)/mime
genmimefiles = \
- mime/cupsfilters.types
-pkgmime_DATA = \
- $(genmimefiles) \
+ mime/cupsfilters.types \
mime/cupsfilters.convs
+pkgmime_DATA = \
+ $(genmimefiles)
+universalmimefiles = \
+ mime/cupsfilters-universal.convs
+individualmimefiles = \
+ mime/cupsfilters-individual.convs
popplermimefiles = \
mime/cupsfilters-poppler.convs
+gsmimefiles = \
+ mime/cupsfilters-ghostscript.convs
+mutoolmimefiles = \
+ mime/cupsfilters-mupdf.convs
+
+if ENABLE_UNIVERSAL_CUPS_FILTER
+if ENABLE_POPPLER
+if ENABLE_GHOSTSCRIPT
+pkgmime_DATA += $(universalmimefiles)
+endif
+endif
+endif
+
+if ENABLE_INDIVIDUAL_CUPS_FILTERS
+pkgmime_DATA += $(individualmimefiles)
if ENABLE_POPPLER
pkgmime_DATA += $(popplermimefiles)
endif
-gsmimefiles = \
- mime/cupsfilters-ghostscript.convs
if ENABLE_GHOSTSCRIPT
pkgmime_DATA += $(gsmimefiles)
endif
-mutoolmimefiles = \
- mime/cupsfilters-mupdf.convs
if ENABLE_MUTOOL
pkgmime_DATA += $(mutoolmimefiles)
endif
+endif
brlmimefiles = \
mime/braille.convs \
EXTRA_DIST += \
$(genmimefiles) \
+ $(universalmimefiles) \
+ $(individualmimefiles) \
$(popplermimefiles) \
$(gsmimefiles) \
$(mutoolmimefiles) \
- $(brlmimefiles) \
- mime/cupsfilters.convs.in
+ $(brlmimefiles)
# =================
# Braille aux files
# ==========
# PDF to PDF
# ==========
+if ENABLE_INDIVIDUAL_CUPS_FILTERS
pkgfilter_PROGRAMS += pdftopdf
+endif
pdftopdf_SOURCES = \
filter/pdftopdf.c
# ======================
genfilterscripts = \
filter/texttops
+if ENABLE_INDIVIDUAL_CUPS_FILTERS
pkgfilter_SCRIPTS = $(genfilterscripts)
+endif
if ENABLE_BRAILLE
nodist_pkgfilter_SCRIPTS = \
filter/braille/drivers/generic/brftoembosser \
commandtoescpx \
commandtopclx \
texttotext \
- pdftops \
rastertoescpx \
- rastertopclx \
+ rastertopclx
+if ENABLE_GHOSTSCRIPT
+pkgfilter_PROGRAMS += \
+ gstopxl
+endif
+if ENABLE_FOOMATIC
+pkgfilter_PROGRAMS += \
+ foomatic-rip
+endif
+if ENABLE_UNIVERSAL_CUPS_FILTER
+if ENABLE_POPPLER
+if ENABLE_GHOSTSCRIPT
+pkgfilter_PROGRAMS += \
+ universal
+endif
+endif
+endif
+if ENABLE_INDIVIDUAL_CUPS_FILTERS
+pkgfilter_PROGRAMS += \
+ pdftops \
texttopdf \
rastertopclm \
rastertopdf \
bannertopdf \
rastertops \
pwgtoraster \
- pclmtoraster \
- universal
+ pclmtoraster
if ENABLE_RASTERTOPWG
pkgfilter_PROGRAMS += \
rastertopwg
pkgfilter_PROGRAMS += \
pstops
endif
-if ENABLE_URFTOPDF
-pkgfilter_PROGRAMS += \
- urftopdf
-endif
if ENABLE_POPPLER
pkgfilter_PROGRAMS += \
pdftoraster
if ENABLE_GHOSTSCRIPT
pkgfilter_PROGRAMS += \
gstoraster \
- gstopdf \
- gstopxl
+ gstopdf
endif
if ENABLE_MUTOOL
pkgfilter_PROGRAMS += \
mupdftoraster
endif
-if ENABLE_FOOMATIC
-pkgfilter_PROGRAMS += \
- foomatic-rip
-endif
if ENABLE_IMAGEFILTERS
pkgfilter_PROGRAMS += \
imagetopdf \
imagetops \
imagetoraster
endif
+endif
check_PROGRAMS += \
test_pdf1 \
$(CUPS_LIBS) \
libcupsfilters.la
-urftopdf_SOURCES = \
- filter/urftopdf.cpp \
- filter/unirast.h
-urftopdf_CXXFLAGS = \
- $(LIBQPDF_CFLAGS)
-urftopdf_LDADD = \
- $(LIBQPDF_LIBS)
-
pclmtoraster_SOURCES = \
filter/pclmtoraster.c
pclmtoraster_CXXFLAGS = \
AM_CONDITIONAL([ENABLE_DRIVERLESS],
[test "x$enable_driverless" != "xno"])
-APPLE_RASTER_FILTER=rastertopdf
-AX_COMPARE_VERSION([$CUPS_VERSION],[lt],[2.2.2], [
- APPLE_RASTER_FILTER=urftopdf
-])
-AC_ARG_WITH([apple-raster-filter],
- [AS_HELP_STRING([--with-apple-raster-filter=rastertopdf|urftopdf], [Select filter for Apple Raster input. Default: rastertopdf for CUPS 2.2.2+, urftopdf for older CUPS])],
- [with_apple_raster_filter="$withval"],
- [with_apple_raster_filter="$APPLE_RASTER_FILTER"]
-)
-AS_CASE([x$with_apple_raster_filter],
- [xrastertopdf|xurftopdf], [APPLE_RASTER_FILTER=$with_apple_raster_filter],
- [AC_MSG_ERROR([Unknown value of with-apple-raster-filter provided: $with_apple_raster_filter])]
-)
-AM_CONDITIONAL([ENABLE_URFTOPDF],
- [test "x$APPLE_RASTER_FILTER" = "xurftopdf"])
-AC_SUBST(APPLE_RASTER_FILTER)
-
AC_DEFINE(PDFTOPDF, [], [Needed for pdftopdf filter compilation])
AC_DEFINE_DIR(BANNERTOPDF_DATADIR, "{CUPS_DATADIR}/data", [Directory where bannertopdf finds its data files (PDF templates)])
PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.0.0])
PKG_CHECK_MODULES([ZLIB], [zlib])
AC_DEFINE([HAVE_LIBZ], [], [Define that we use zlib])
-PKG_CHECK_MODULES([LIBQPDF], [libqpdf >= 8.3.0])
-
-# ===============================
-# Check for PCLm printing support
-# ===============================
-AC_ARG_ENABLE([pclm], [AS_HELP_STRING([--enable-pclm], [enable PCLm printing.])],
- [enable_pclm="$enableval"],
- [enable_pclm=yes]
-)
-if test "x$enable_pclm" != "xno"; then
- AC_DEFINE([QPDF_HAVE_PCLM], [1], [QPDF has PCLm support?])
- QPDF_NO_PCLM=
-else
- QPDF_NO_PCLM=\#
-fi
-AC_SUBST(QPDF_NO_PCLM)
-
-
+PKG_CHECK_MODULES([LIBQPDF], [libqpdf >= 10.3.2])
# =================
# Check for Poppler
)
AM_CONDITIONAL([ENABLE_RASTERTOPWG], [test "x$enable_rastertopwg" = "xyes"])
+# ===============================
+# Check for universal CUPS filter
+# ===============================
+AC_ARG_ENABLE([universal-cups-filter],
+ [AS_HELP_STRING([--enable-universal-cups-filter], [Create single, universal CUPS filter executable for all filter functions.])],
+ [enable_universal_cups_filter="$enableval"],
+ [enable_universal_cups_filter=yes]
+)
+AM_CONDITIONAL([ENABLE_UNIVERSAL_CUPS_FILTER],
+[test "x$enable_universal_cups_filter" != "xno"])
+
+# =================================
+# Check for individual CUPS filters
+# =================================
+AC_ARG_ENABLE([individual-cups-filters],
+ [AS_HELP_STRING([--enable-individual-cups-filters], [Create individual CUPS filter executables for each filter function.])],
+ [enable_individual_cups_filters="$enableval"],
+ [enable_individual_cups_filters=no]
+)
+AM_CONDITIONAL([ENABLE_INDIVIDUAL_CUPS_FILTERS],
+[test "x$enable_individual_cups_filters" != "xno"])
+
# =============
# Check for php
# =============
filter/braille/filters/vectortobrf
filter/braille/filters/musicxmltobrf
filter/braille/filters/liblouis1.defs.gen
- mime/cupsfilters.convs
])
AC_CONFIG_COMMANDS([executable-scripts], [
chmod +x filter/braille/filters/liblouis1.defs.gen
werror: ${enable_werror}
braille: ${enable_braille}
braille tables: ${TABLESDIR}
+ universal CUPS filter: ${enable_universal_cups_filter}
+ individual CUPS filters: ${enable_individual_cups_filters}
driverless: ${enable_driverless}
- apple-raster: ${APPLE_RASTER_FILTER}
pclm: ${enable_pclm}
ppdc utilities: ${enable_ppdc_utils}
local queue naming for remote CUPS queues: ${REMOTE_CUPS_LOCAL_QUEUE_NAMING}
}
}
}
-#ifdef QPDF_HAVE_PCLM
if (cupsArrayFind(pdl_list, "application/PCLm")) {
if ((attr = ippFindAttribute(response, "pclm-source-resolution-supported",
IPP_TAG_RESOLUTION)) != NULL) {
}
}
}
-#endif
/* Legacy formats only if we have no driverless format */
if (!is_pdf && !is_apple && !is_pwg && !is_pclm) {
if (cupsArrayFind(pdl_list, "application/vnd.hp-pclxl")) {
while (attr) { /* loop through all the attributes */
if ((is_apple && strncasecmp(ippGetName(attr), "urf-", 4) == 0) ||
(is_pwg && strncasecmp(ippGetName(attr), "pwg-raster-", 11) == 0)
-#ifdef QPDF_HAVE_PCLM
|| (is_pclm && strncasecmp(ippGetName(attr), "pclm-", 5) == 0)
-#endif
) {
ppdPwgPpdizeName(ippGetName(attr), ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*cups%s: ", ppdname);
#include <qpdf/Pl_Flate.hh>
#include <qpdf/Pl_Buffer.hh>
-#ifdef QPDF_HAVE_PCLM
#include <qpdf/Pl_RunLength.hh>
#include <qpdf/Pl_DCT.hh>
-#endif
#ifdef USE_LCMS1
#include <lcms.h>
return ret;
}
-#ifdef QPDF_HAVE_PCLM
/**
* 'makePclmStrips()' - return an std::vector of QPDFObjectHandle, each
* containing the stream data of the various strips
}
return ret;
}
-#endif
QPDFObjectHandle makeImage(QPDF &pdf, PointerHolder<Buffer> page_data,
unsigned width, unsigned height,
// add it
info->page.getKey("/Resources").getKey("/XObject").replaceKey("/I",image);
}
-#ifdef QPDF_HAVE_PCLM
else if (info->outformat == OUTPUT_FORMAT_PCLM)
{
// Finish previous PCLm page
int_to_fwstring(i, num_digits(info->pclm_num_strips - 1)),
strips[i]);
}
-#endif
// draw it
std::string content;
QUtil::double_to_string(info->page_height) + " 0 0 cm\n");
content.append("/I Do\n");
}
-#ifdef QPDF_HAVE_PCLM
else if (info->outformat == OUTPUT_FORMAT_PCLM)
{
std::string res = info->pclm_source_resolution_default;
" Do Q\n");
}
}
-#endif
QPDFObjectHandle page_contents = info->page.getKey("/Contents");
if (info->outformat == OUTPUT_FORMAT_PDF)
page_contents.replaceStreamData(content, QPDFObjectHandle::newNull(),
QPDFObjectHandle::newNull());
-#ifdef QPDF_HAVE_PCLM
else if (info->outformat == OUTPUT_FORMAT_PCLM)
page_contents.getArrayItem(0).replaceStreamData(content,
QPDFObjectHandle::newNull(),
QPDFObjectHandle::newNull());
-#endif
// bookkeeping
info->page_data = PointerHolder<Buffer>();
-#ifdef QPDF_HAVE_PCLM
info->pclm_strip_data.clear();
-#endif
return 0;
}
QPDFWriter output(info->pdf,NULL);
output.setOutputFile("pdf", doc->outputfp, false);
// output.setMinimumPDFVersion("1.4");
-#ifdef QPDF_HAVE_PCLM
if (info->outformat == OUTPUT_FORMAT_PCLM)
output.setPCLm(true);
-#endif
output.write();
} catch (...) {
return 1;
(void)inputseekable;
-#ifdef QPDF_HAVE_PCLM
if (parameters)
{
outformat = *(filter_out_format_t *)parameters;
}
else
outformat = OUTPUT_FORMAT_PDF;
-#else
- outformat = OUTPUT_FORMAT_PDF;
-#endif
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"rastertopdf: OUTFORMAT=\"%s\"",
outformat == OUTPUT_FORMAT_PDF ? "PDF" : "PCLM");
else
doc.cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER"));
-#ifdef QPDF_HAVE_PCLM
if (outformat == OUTPUT_FORMAT_PCLM && data->ppd == NULL
&& printer_attrs == NULL )
{
"rastertopdf: PCLm output: Neither a PPD file nor printer IPP attributes are supplied, PCLm output not possible.");
return 1;
}
-#endif
// Transform
ras = cupsRasterOpen(inputfd, CUPS_RASTER_READ);
+++ /dev/null
-/**
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @brief Decode URF to a PDF file
- * @file urftopdf.cpp
- * @author Neil 'Superna' Armstrong <superna9999@gmail.com> (C) 2010
- * @author Tobias Hoffmann <smilingthax@gmail.com> (c) 2012
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits>
-#include <errno.h>
-
-#include <arpa/inet.h> // ntohl
-
-#include <vector>
-#include <qpdf/QPDF.hh>
-#include <qpdf/QPDFWriter.hh>
-#include <qpdf/QUtil.hh>
-
-#include <qpdf/Pl_Flate.hh>
-#include <qpdf/Pl_Buffer.hh>
-
-#include "unirast.h"
-
-#define DEFAULT_PDF_UNIT 72 // 1/72 inch
-
-#define PROGRAM "urftopdf"
-
-#ifdef URF_DEBUG
-#define dprintf(format, ...) fprintf(stderr, "DEBUG: (" PROGRAM ") " format, __VA_ARGS__)
-#else
-#define dprintf(format, ...)
-#endif
-
-#define iprintf(format, ...) fprintf(stderr, "INFO: (" PROGRAM ") " format, __VA_ARGS__)
-
-void die(const char * str)
-{
- fprintf(stderr, "CRIT: (" PROGRAM ") die(%s) [%s]\n", str, strerror(errno));
- exit(1);
-}
-
-//------------- PDF ---------------
-
-struct pdf_info
-{
- pdf_info()
- : pagecount(0),
- width(0),height(0),
- pixel_bytes(0),line_bytes(0),
- bpp(0),
- page_width(0),page_height(0)
- {
- }
-
- QPDF pdf;
- QPDFObjectHandle page;
- unsigned pagecount;
- unsigned width;
- unsigned height;
- unsigned pixel_bytes;
- unsigned line_bytes;
- unsigned bpp;
- PointerHolder<Buffer> page_data;
- double page_width,page_height;
-};
-
-int create_pdf_file(struct pdf_info * info, unsigned pagecount)
-{
- try {
- info->pdf.emptyPDF();
- } catch (...) {
- return 1;
- }
-
- info->pagecount = pagecount;
-
- return 0;
-}
-
-QPDFObjectHandle makeBox(double x1, double y1, double x2, double y2)
-{
- QPDFObjectHandle ret=QPDFObjectHandle::newArray();
- ret.appendItem(QPDFObjectHandle::newReal(x1));
- ret.appendItem(QPDFObjectHandle::newReal(y1));
- ret.appendItem(QPDFObjectHandle::newReal(x2));
- ret.appendItem(QPDFObjectHandle::newReal(y2));
- return ret;
-}
-
-enum ColorSpace {
- DEVICE_GRAY,
- DEVICE_RGB,
- DEVICE_CMYK
-};
-
-#define PRE_COMPRESS
-/* or temporarily store images?
- if(cupsTempFile2(tempfile_name, 255) == NULL) die("Unable to create a temporary pdf file");
- iprintf("Created temporary file '%s'\n", tempfile_name);
-*/
-
-QPDFObjectHandle makeImage(QPDF &pdf, PointerHolder<Buffer> page_data, unsigned width, unsigned height, ColorSpace cs, unsigned bpc)
-{
- QPDFObjectHandle ret = QPDFObjectHandle::newStream(&pdf);
-
- std::map<std::string,QPDFObjectHandle> dict;
-
- dict["/Type"]=QPDFObjectHandle::newName("/XObject");
- dict["/Subtype"]=QPDFObjectHandle::newName("/Image");
- dict["/Width"]=QPDFObjectHandle::newInteger(width);
- dict["/Height"]=QPDFObjectHandle::newInteger(height);
- dict["/BitsPerComponent"]=QPDFObjectHandle::newInteger(bpc);
-
- if (cs==DEVICE_GRAY) {
- dict["/ColorSpace"]=QPDFObjectHandle::newName("/DeviceGray");
- } else if (cs==DEVICE_RGB) {
- dict["/ColorSpace"]=QPDFObjectHandle::newName("/DeviceRGB");
- } else if (cs==DEVICE_CMYK) {
- dict["/ColorSpace"]=QPDFObjectHandle::newName("/DeviceCMYK");
- } else {
- return QPDFObjectHandle();
- }
-
- ret.replaceDict(QPDFObjectHandle::newDictionary(dict));
-
-#ifdef PRE_COMPRESS
- // we deliver already compressed content (instead of letting QPDFWriter do it), to avoid using excessive memory
- Pl_Buffer psink("psink");
- Pl_Flate pflate("pflate",&psink,Pl_Flate::a_deflate);
-
- pflate.write(page_data->getBuffer(),page_data->getSize());
- pflate.finish();
-
-// /Filter /FlateDecode
-// /DecodeParms [<</Predictor 1 /Colors 1[3] /BitsPerComponent $bits /Columns $x>>] ??
- ret.replaceStreamData(PointerHolder<Buffer>(psink.getBuffer()),
- QPDFObjectHandle::newName("/FlateDecode"),QPDFObjectHandle::newNull());
-#else
- ret.replaceStreamData(page_data,QPDFObjectHandle::newNull(),QPDFObjectHandle::newNull());
-#endif
-
- return ret;
-}
-
-void finish_page(struct pdf_info * info)
-{
- //Finish previous Page
- if(!info->page_data.getPointer())
- return;
-
- QPDFObjectHandle image = makeImage(info->pdf, info->page_data, info->width, info->height, DEVICE_RGB, 8);
- if(!image.isInitialized()) die("Unable to load image data");
-
- // add it
- info->page.getKey("/Resources").getKey("/XObject").replaceKey("/I",image);
-
- // draw it
- std::string content;
- content.append(QUtil::double_to_string(info->page_width) + " 0 0 " +
- QUtil::double_to_string(info->page_height) + " 0 0 cm\n");
- content.append("/I Do\n");
- info->page.getKey("/Contents").replaceStreamData(content,QPDFObjectHandle::newNull(),QPDFObjectHandle::newNull());
-
- // bookkeeping
- info->page_data = PointerHolder<Buffer>();
-}
-
-int add_pdf_page(struct pdf_info * info, int pagen, unsigned width, unsigned height, int bpp, unsigned dpi)
-{
- try {
- finish_page(info); // any active
-
- info->width = width;
- info->height = height;
- info->pixel_bytes = bpp/8;
- info->line_bytes = (width*info->pixel_bytes);
- info->bpp = bpp;
-
- if (info->height > (std::numeric_limits<unsigned>::max() / info->line_bytes)) {
- die("Page too big");
- }
- info->page_data = PointerHolder<Buffer>(new Buffer(info->line_bytes*info->height));
-
- QPDFObjectHandle page = QPDFObjectHandle::parse(
- "<<"
- " /Type /Page"
- " /Resources <<"
- " /XObject << >> "
- " >>"
- " /MediaBox null "
- " /Contents null "
- ">>");
- page.replaceKey("/Contents",QPDFObjectHandle::newStream(&info->pdf)); // data will be provided later
-
- // Convert to pdf units
- info->page_width=((double)info->width/dpi)*DEFAULT_PDF_UNIT;
- info->page_height=((double)info->height/dpi)*DEFAULT_PDF_UNIT;
- page.replaceKey("/MediaBox",makeBox(0,0,info->page_width,info->page_height));
-
- info->page = info->pdf.makeIndirectObject(page); // we want to keep a reference
- info->pdf.addPage(info->page, false);
- } catch (std::bad_alloc &ex) {
- die("Unable to allocate page data");
- } catch (...) {
- return 1;
- }
-
- return 0;
-}
-
-int close_pdf_file(struct pdf_info * info)
-{
- try {
- finish_page(info); // any active
-
- QPDFWriter output(info->pdf,NULL);
- output.write();
- } catch (...) {
- return 1;
- }
-
- return 0;
-}
-
-void pdf_set_line(struct pdf_info * info, unsigned line_n, uint8_t line[])
-{
- dprintf("pdf_set_line(%d)\n", line_n);
-
- if(line_n > info->height)
- {
- dprintf("Bad line %d\n", line_n);
- return;
- }
-
- memcpy((info->page_data->getBuffer()+(line_n*info->line_bytes)), line, info->line_bytes);
-}
-
-// Data are in network endianness
-struct urf_file_header {
- char unirast[8];
- uint32_t page_count;
-} __attribute__((__packed__));
-
-struct urf_page_header {
- uint8_t bpp;
- uint8_t colorspace;
- uint8_t duplex;
- uint8_t quality;
- uint32_t unknown0;
- uint32_t unknown1;
- uint32_t width;
- uint32_t height;
- uint32_t dot_per_inch;
- uint32_t unknown2;
- uint32_t unknown3;
-} __attribute__((__packed__));
-
-int decode_raster(int fd, unsigned width, unsigned height, int bpp, struct pdf_info * info)
-{
- // We should be at raster start
- int i, j;
- unsigned cur_line = 0;
- unsigned pos = 0;
- uint8_t line_repeat_byte = 0;
- unsigned line_repeat = 0;
- int8_t packbit_code = 0;
- int pixel_size = (bpp/8);
- std::vector<uint8_t> pixel_container;
- std::vector<uint8_t> line_container;
-
- if (width > (std::numeric_limits<unsigned>::max() / pixel_size)) {
- die("Line too big");
- }
- try {
- pixel_container.resize(pixel_size);
- line_container.resize(pixel_size*width);
- } catch (...) {
- die("Unable to allocate temporary storage");
- }
-
- do
- {
- if(read(fd, &line_repeat_byte, 1) < 1)
- {
- dprintf("l%06d : line_repeat EOF at %lu\n", cur_line, lseek(fd, 0, SEEK_CUR));
- return 1;
- }
-
- line_repeat = (unsigned)line_repeat_byte + 1;
-
- dprintf("l%06d : next actions for %d lines\n", cur_line, line_repeat);
-
- // Start of line
- pos = 0;
-
- do
- {
- if(read(fd, &packbit_code, 1) < 1)
- {
- dprintf("p%06dl%06d : packbit_code EOF at %lu\n", pos, cur_line, lseek(fd, 0, SEEK_CUR));
- return 1;
- }
-
- dprintf("p%06dl%06d: Raster code %02X='%d'.\n", pos, cur_line, (uint8_t)packbit_code, packbit_code);
-
- if(packbit_code == -128)
- {
- dprintf("\tp%06dl%06d : blank rest of line.\n", pos, cur_line);
- memset((&line_container[pos*pixel_size]), 0xFF, (pixel_size*(width-pos)));
- pos = width;
- break;
- }
- else if(packbit_code >= 0 && packbit_code <= 127)
- {
- int n = (packbit_code+1);
-
- //Read pixel
- if(read(fd, &pixel_container[0], pixel_size) < pixel_size)
- {
- dprintf("p%06dl%06d : pixel repeat EOF at %lu\n", pos, cur_line, lseek(fd, 0, SEEK_CUR));
- return 1;
- }
-
- dprintf("\tp%06dl%06d : Repeat pixel '", pos, cur_line);
- for(j = 0 ; j < pixel_size ; ++j)
- dprintf("%02X ", pixel_container[j]);
- dprintf("' for %d times.\n", n);
-
- for(i = 0 ; i < n ; ++i)
- {
- //for(j = pixel_size-1 ; j >= 0 ; --j)
- for(j = 0 ; j < pixel_size ; ++j)
- line_container[pixel_size*pos + j] = pixel_container[j];
- ++pos;
- if(pos >= width)
- break;
- }
-
- if(i < n && pos >= width)
- {
- dprintf("\tp%06dl%06d : Forced end of line for pixel repeat.\n", pos, cur_line);
- }
-
- if(pos >= width)
- break;
- }
- else if(packbit_code > -128 && packbit_code < 0)
- {
- int n = (-(int)packbit_code)+1;
-
- dprintf("\tp%06dl%06d : Copy %d verbatim pixels.\n", pos, cur_line, n);
-
- for(i = 0 ; i < n ; ++i)
- {
- if(read(fd, &pixel_container[0], pixel_size) < pixel_size)
- {
- dprintf("p%06dl%06d : literal_pixel EOF at %lu\n", pos, cur_line, lseek(fd, 0, SEEK_CUR));
- return 1;
- }
- //Invert pixels, should be programmable
- for(j = 0 ; j < pixel_size ; ++j)
- line_container[pixel_size*pos + j] = pixel_container[j];
- ++pos;
- if(pos >= width)
- break;
- }
-
- if(i < n && pos >= width)
- {
- dprintf("\tp%06dl%06d : Forced end of line for pixel copy.\n", pos, cur_line);
- }
-
- if(pos >= width)
- break;
- }
- }
- while(pos < width);
-
- dprintf("\tl%06d : End Of line, drawing %d times.\n", cur_line, line_repeat);
-
- // write lines
- for(i = 0 ; i < (int)line_repeat ; ++i)
- {
- pdf_set_line(info, cur_line, &line_container[0]);
- ++cur_line;
- }
- }
- while(cur_line < height);
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- int fd, page;
- struct urf_file_header head, head_orig;
- struct urf_page_header page_header, page_header_orig;
- struct pdf_info pdf;
-
- FILE * input = NULL;
-
- if(argc < 6)
- {
- fprintf(stderr, "Usage: %s <job> <user> <job name> <copies> <option> [file]\n", argv[0]);
- return 1;
- }
-
- if(argc > 6)
- {
- input = fopen(argv[6], "rb");
- if(input == NULL) die("Unable to open unirast file");
- }
- else
- input = stdin;
-
- // Get fd from file
- fd = fileno(input);
-
- if(read(fd, &head_orig, sizeof(head)) == -1) die("Unable to read file header");
-
- //Transform
- memcpy(head.unirast, head_orig.unirast, sizeof(head.unirast));
- head.page_count = ntohl(head_orig.page_count);
-
- if(head.unirast[7])
- head.unirast[7] = 0;
-
- if(strncmp(head.unirast, "UNIRAST", 7) != 0) die("Bad File Header");
-
- iprintf("%s file, with %d page(s).\n", head.unirast, head.page_count);
-
- if(create_pdf_file(&pdf, head.page_count) != 0) die("Unable to create PDF file");
-
- for(page = 0 ; page < (int)head.page_count ; ++page)
- {
- if(read(fd, &page_header_orig, sizeof(page_header_orig)) == -1) die("Unable to read page header");
-
- //Transform
- page_header.bpp = page_header_orig.bpp;
- page_header.colorspace = page_header_orig.colorspace;
- page_header.duplex = page_header_orig.duplex;
- page_header.quality = page_header_orig.quality;
- page_header.unknown0 = 0;
- page_header.unknown1 = 0;
- page_header.width = ntohl(page_header_orig.width);
- page_header.height = ntohl(page_header_orig.height);
- page_header.dot_per_inch = ntohl(page_header_orig.dot_per_inch);
- page_header.unknown2 = 0;
- page_header.unknown3 = 0;
-
- iprintf("Page %d :\n", page);
- iprintf("Bits Per Pixel : %d\n", page_header.bpp);
- iprintf("Colorspace : %d\n", page_header.colorspace);
- iprintf("Duplex Mode : %d\n", page_header.duplex);
- iprintf("Quality : %d\n", page_header.quality);
- iprintf("Size : %dx%d pixels\n", page_header.width, page_header.height);
- iprintf("Dots per Inches : %d\n", page_header.dot_per_inch);
-
- if(page_header.colorspace != UNIRAST_COLOR_SPACE_SRGB_24BIT_1)
- {
- die("Invalid ColorSpace, only RGB 24BIT type 1 is supported");
- }
-
- if(page_header.bpp != UNIRAST_BPP_24BIT)
- {
- die("Invalid Bit Per Pixel value, only 24bit is supported");
- }
-
- if(add_pdf_page(&pdf, page, page_header.width, page_header.height, page_header.bpp, page_header.dot_per_inch) != 0) die("Unable to create PDF file");
-
- if(decode_raster(fd, page_header.width, page_header.height, page_header.bpp, &pdf) != 0)
- die("Failed to decode Page");
- }
-
- close_pdf_file(&pdf); // will output to stdout
-
- return 0;
-}
--- /dev/null
+#
+# MIME conversions file for OpenPrinting CUPS Filters.
+#
+# Copyright 2007-2011 by Apple Inc.
+# Copyright 1997-2007 by Easy Software Products.
+# Copyright 2012-2016 by Till Kamppeter.
+# Copyright 2017 by Sahil Arora.
+#
+# These coded instructions, statements, and computer programs are the
+# property of Apple Inc. and are protected by Federal copyright
+# law. Distribution and use rights are outlined in the file "COPYING"
+# which should have been included with this file.
+#
+
+########################################################################
+#
+# Format of Lines:
+#
+# source/type destination/type cost filter
+#
+# General Notes:
+#
+# The "cost" field is used to find the least costly filters to run
+# when converting a job file to a printable format.
+#
+# All filters *must* accept the standard command-line arguments
+# (job-id, user, title, copies, options, [filename or stdin]) to
+# work with CUPS.
+#
+
+########################################################################
+#
+# Input formats
+#
+
+image/jpeg application/vnd.universal-input 0 -
+image/png application/vnd.universal-input 0 -
+image/gif application/vnd.universal-input 0 -
+image/tiff application/vnd.universal-input 0 -
+image/x-bitmap application/vnd.universal-input 0 -
+image/x-photocd application/vnd.universal-input 0 -
+image/x-portable-anymap application/vnd.universal-input 0 -
+image/x-portable-bitmap application/vnd.universal-input 0 -
+image/x-portable-graymap application/vnd.universal-input 0 -
+image/x-portable-pixmap application/vnd.universal-input 0 -
+image/x-sgi-rgb application/vnd.universal-input 0 -
+image/x-xbitmap application/vnd.universal-input 0 -
+image/x-xpixmap application/vnd.universal-input 0 -
+image/x-xwindowdump application/vnd.universal-input 0 -
+image/x-sun-raster application/vnd.universal-input 0 -
+image/pwg-raster application/vnd.universal-input 0 -
+application/vnd.cups-pdf application/vnd.universal-input 0 -
+application/vnd.cups-raster application/vnd.universal-input 0 -
+image/urf application/vnd.universal-input 0 -
+application/postscript application/vnd.universal-input 0 -
+application/pdf application/vnd.universal-input 0 -
+text/plain application/vnd.universal-input 0 -
+application/PCLm application/vnd.universal-input 0 -
+
+# CUPS file conversion rules for PostScript input when we are working
+# with the PDF printing workflow: General PostScript input should be
+# converted to PDF, so that pdftopdf() is doing the page management on
+# PDF data and the renderer/driver part renders PDF. An exception is
+# made for PostScript coming from the Adobe Reader. As this PostScript
+# cannot be converted to PDF if it comes from an encrypted PDF file,
+# we simply override pstopdf() and the PDF workflow.
+
+application/vnd.adobe-reader-postscript application/vnd.universal-input 0 -
+
+########################################################################
+#
+# Output formats
+#
+
+application/vnd.universal-input application/pdf 0 universal
+application/vnd.universal-input application/vnd.cups-pdf 0 universal
+application/vnd.universal-input application/vnd.cups-postscript 0 universal
+application/vnd.universal-input application/postscript 0 universal
+application/vnd.universal-input application/vnd.cups-raster 0 universal
+application/vnd.universal-input image/pwg-raster 0 universal
+application/vnd.universal-input image/urf 0 universal
+application/vnd.universal-input application/PCLm 0 universal
--- /dev/null
+#
+# MIME conversions file for OpenPrinting CUPS Filters.
+#
+# Copyright 2007-2011 by Apple Inc.
+# Copyright 1997-2007 by Easy Software Products.
+# Copyright 2012-2021 by Till Kamppeter.
+# Copyright 2017 by Sahil Arora.
+#
+# These coded instructions, statements, and computer programs are the
+# property of Apple Inc. and are protected by Federal copyright
+# law. Distribution and use rights are outlined in the file "COPYING"
+# which should have been included with this file.
+#
+
+########################################################################
+#
+# Format of Lines:
+#
+# source/type destination/type cost filter
+#
+# General Notes:
+#
+# The "cost" field is used to find the least costly filters to run
+# when converting a job file to a printable format.
+#
+# All filters *must* accept the standard command-line arguments
+# (job-id, user, title, copies, options, [filename or stdin]) to
+# work with CUPS.
+#
+
+########################################################################
+#
+# Text rules (for text-only printers with texttotext filter in PPD and
+# for texttopdf, both individual or in universal filter)...
+#
+
+application/x-cshell text/plain 0 -
+application/x-csource text/plain 0 -
+application/x-perl text/plain 0 -
+application/x-shell text/plain 0 -
+text/html text/plain 0 -
+text/css text/plain 0 -
+++ /dev/null
-#
-# MIME conversions file for OpenPrinting CUPS Filters.
-#
-# Copyright 2007-2011 by Apple Inc.
-# Copyright 1997-2007 by Easy Software Products.
-# Copyright 2012-2016 by Till Kamppeter.
-# Copyright 2017 by Sahil Arora.
-#
-# These coded instructions, statements, and computer programs are the
-# property of Apple Inc. and are protected by Federal copyright
-# law. Distribution and use rights are outlined in the file "COPYING"
-# which should have been included with this file.
-#
-
-########################################################################
-#
-# Format of Lines:
-#
-# source/type destination/type cost filter
-#
-# General Notes:
-#
-# The "cost" field is used to find the least costly filters to run
-# when converting a job file to a printable format.
-#
-# All filters *must* accept the standard command-line arguments
-# (job-id, user, title, copies, options, [filename or stdin]) to
-# work with CUPS.
-#
-
-########################################################################
-#
-# PDF filters
-#
-
-# CUPS file conversion rules for PostScript input when we are working with
-# the PDF printing workflow. General PostScript input should be converted to
-# PDF (see cupsfilters-ghostscript.convs as this is done by Ghostscript), so
-# that pdftopdf is doing the page management on PDF data and the
-# renderer/driver part renders PDF. An exception is made for PostScript
-# coming from the Adobe Reader. As this PostScript cannot be converted to PDF
-# if it comes from an encrypted PDF file, we simply override pstopdf and the
-# PDF workflow.
-
-application/vnd.adobe-reader-postscript application/vnd.cups-postscript 66 pstops
-
-application/pdf application/vnd.cups-pdf 66 pdftopdf
-application/x-cshell application/pdf 32 texttopdf
-application/x-csource application/pdf 32 texttopdf
-application/x-perl application/pdf 32 texttopdf
-application/x-shell application/pdf 32 texttopdf
-text/plain application/pdf 32 texttopdf
-text/html application/pdf 32 texttopdf
-image/pwg-raster application/pdf 32 rastertopdf
-image/gif application/vnd.cups-pdf 65 imagetopdf
-image/png application/vnd.cups-pdf 65 imagetopdf
-image/jpeg application/vnd.cups-pdf 65 imagetopdf
-image/tiff application/vnd.cups-pdf 65 imagetopdf
-image/x-bitmap application/vnd.cups-pdf 65 imagetopdf
-image/x-photocd application/vnd.cups-pdf 65 imagetopdf
-image/x-portable-anymap application/vnd.cups-pdf 65 imagetopdf
-image/x-portable-bitmap application/vnd.cups-pdf 65 imagetopdf
-image/x-portable-graymap application/vnd.cups-pdf 65 imagetopdf
-image/x-portable-pixmap application/vnd.cups-pdf 65 imagetopdf
-image/x-sgi-rgb application/vnd.cups-pdf 65 imagetopdf
-image/x-xbitmap application/vnd.cups-pdf 65 imagetopdf
-image/x-xpixmap application/vnd.cups-pdf 65 imagetopdf
-image/x-xwindowdump application/vnd.cups-pdf 65 imagetopdf
-image/x-sun-raster application/vnd.cups-pdf 65 imagetopdf
-application/vnd.cups-pdf-banner application/pdf 32 bannertopdf
-image/urf application/pdf 0 @APPLE_RASTER_FILTER@
-@QPDF_NO_PCLM@application/vnd.cups-raster application/PCLm 32 rastertopclm
-
-########################################################################
-#
-# PostScript filters
-#
-
-#application/pdf application/vnd.cups-postscript 66 pdftops
-application/vnd.cups-pdf application/vnd.cups-postscript 100 pdftops
-#application/postscript application/vnd.cups-postscript 66 pstops
-
-########################################################################
-#
-# Raster filters...
-#
-
-application/PCLm application/vnd.cups-raster 32 pclmtoraster
-image/gif application/vnd.cups-raster 100 imagetoraster
-image/png application/vnd.cups-raster 100 imagetoraster
-image/jpeg application/vnd.cups-raster 100 imagetoraster
-image/tiff application/vnd.cups-raster 100 imagetoraster
-image/x-bitmap application/vnd.cups-raster 100 imagetoraster
-image/x-photocd application/vnd.cups-raster 100 imagetoraster
-image/x-portable-anymap application/vnd.cups-raster 100 imagetoraster
-image/x-portable-bitmap application/vnd.cups-raster 100 imagetoraster
-image/x-portable-graymap application/vnd.cups-raster 100 imagetoraster
-image/x-portable-pixmap application/vnd.cups-raster 100 imagetoraster
-image/x-sgi-rgb application/vnd.cups-raster 100 imagetoraster
-image/x-xbitmap application/vnd.cups-raster 100 imagetoraster
-image/x-xpixmap application/vnd.cups-raster 100 imagetoraster
-image/x-sun-raster application/vnd.cups-raster 100 imagetoraster
-
-########################################################################
-#
-# Text filters (only for text-only printers)...
-#
-
-application/x-cshell text/plain 100 -
-application/x-csource text/plain 100 -
-application/x-perl text/plain 100 -
-application/x-shell text/plain 100 -
-text/html text/plain 100 -
-text/css text/plain 100 -
-
application/vnd.cups-pdf-banner string(0,'#PDF-BANNER')
application/PCLm
+########################################################################
+#
+# Auxiliary input type for the universal CUPS filter...
+#
+
+application/vnd.universal-input
+++ /dev/null
-image/jpeg application/vnd.universal-input 0 -
-image/png application/vnd.universal-input 0 -
-image/gif application/vnd.universal-input 0 -
-image/pwg-raster application/vnd.universal-input 0 -
-application/vnd.cups-pdf application/vnd.universal-input 0 -
-application/vnd.cups-raster application/vnd.universal-input 0 -
-image/urf application/vnd.universal-input 0 -
-application/postscript application/vnd.universal-input 0 -
-application/pdf application/vnd.universal-input 0 -
-text/plain application/vnd.universal-input 0 -
-application/PCLm application/vnd.universal-input 0 -
-application/vnd.universal-input application/pdf 0 universal
-application/vnd.universal-input application/vnd.cups-pdf 0 universal
-application/vnd.universal-input application/vnd.cups-postscript 0 universal
-application/vnd.universal-input application/postscript 0 universal
-application/vnd.universal-input application/vnd.cups-raster 0 universal
-application/vnd.universal-input image/pwg-raster 0 universal
-application/vnd.universal-input image/urf 0 universal
-application/vnd.universal-input application/PCLm 0 universal
+++ /dev/null
-application/vnd.universal-input
if (cupsArrayFind(pdl_list, "application/vnd.cups-pdf") ||
cupsArrayFind(pdl_list, "application/pdf"))
strcpy(document_format, "pdf");
-#ifdef CUPS_RASTER_HAVE_APPLERASTER
else if (cupsArrayFind(pdl_list, "image/urf"))
strcpy(document_format, "apple-raster");
-#endif
else if (cupsArrayFind(pdl_list, "image/pwg-raster"))
strcpy(document_format, "raster");
-#ifdef QPDF_HAVE_PCLM
else if (cupsArrayFind(pdl_list, "application/PCLm"))
strcpy(document_format, "pclm");
-#endif
else if (cupsArrayFind(pdl_list, "application/vnd.hp-pclxl"))
strcpy(document_format, "pclxl");
else if (cupsArrayFind(pdl_list, "application/vnd.cups-postscript") ||
(!strcasestr(pdl, "application/postscript") &&
!strcasestr(pdl, "application/pdf") &&
!strcasestr(pdl, "image/pwg-raster") &&
-#ifdef CUPS_RASTER_HAVE_APPLERASTER
!strcasestr(pdl, "image/urf") &&
-#endif
-#ifdef QPDF_HAVE_PCLM
!strcasestr(pdl, "application/PCLm") &&
-#endif
((!strcasestr(pdl, "application/vnd.hp-PCL") &&
!strcasestr(pdl, "application/PCL") &&
!strcasestr(pdl, "application/x-pcl")) ||
debug_printf("Cannot create remote printer %s (URI: %s, Model: %s, Accepted data formats: %s) as its PDLs are not known, ignoring this printer.\n",
p->queue_name, p->uri, make_model, pdl);
debug_printf("Supported PDLs: PWG Raster, %s%sPostScript, PDF, PCL XL, PCL 5c/e (HP inkjets report themselves as PCL printers but their PCL is not supported)\n",
-#ifdef CUPS_RASTER_HAVE_APPLERASTER
"Apple Raster, ",
-#else
- "",
-#endif
-#ifdef QPDF_HAVE_PCLM
"PCLm, "
-#else
- ""
-#endif
);
goto fail;
}
is_pwgraster ? "supports" : "does not support");
}
-#ifdef CUPS_RASTER_HAVE_APPLERASTER
/* If we have opted for only Apple Raster printers or for only printers
designed for driverless use (PWG Raster + Apple Raster + PCLm + PDF)
being set up automatically, we check whether the printer has a non-empty
debug_printf(" --> Printer %s Apple Raster.\n",
is_appleraster ? "supports" : "does not support");
}
-#endif
-#ifdef QPDF_HAVE_PCLM
/* If we have opted for only PCLm printers or for only printers
designed for driverless use (PWG Raster + Apple Raster + PCLm + PDF)
being set up automatically, we check whether the printer has a non-empty
debug_printf(" --> Printer %s PCLm.\n",
is_pclm ? "supports" : "does not support");
}
-#endif
/* If we have opted for only PDF printers or for only printers
designed for driverless use (PWG Raster + Apple Raster + PCLm + PDF)
ippfind_argv[i++] = "(";
ippfind_argv[i++] = "--txt-pdl"; /* PDL list in TXT record contains */
ippfind_argv[i++] = "image/pwg-raster"; /* PWG Raster (IPP Everywhere) */
-#ifdef QPDF_HAVE_PCLM
ippfind_argv[i++] = "--or"; /* or */
ippfind_argv[i++] = "--txt-pdl";
ippfind_argv[i++] = "application/PCLm"; /* PCLm */
-#endif
-#ifdef CUPS_RASTER_HAVE_APPLERASTER
ippfind_argv[i++] = "--or"; /* or */
ippfind_argv[i++] = "--txt-pdl";
ippfind_argv[i++] = "image/urf"; /* Apple Raster */
-#endif
ippfind_argv[i++] = "--or"; /* or */
ippfind_argv[i++] = "--txt-pdl";
ippfind_argv[i++] = "application/pdf"; /* PDF */