diff -Nru cups-filters-1.0.17/CHANGES.txt cups-filters-1.0.18/CHANGES.txt --- cups-filters-1.0.17/CHANGES.txt 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/CHANGES.txt 2012-05-16 11:02:01.000000000 +0200 @@ -1,6 +1,37 @@ -CHANGES.txt - OpenPrinting CUPS Filters v1.0.17 - 2012-04-20 +CHANGES.txt - OpenPrinting CUPS Filters v1.0.18 - 2012-05-16 ------------------------------------------------------------ +CHANGES IN V1.0.18 + + - Modified "./configure" options related to the pdftops filter to + allow changing the defaults for the renderer being used by default + (Ghostscript or Poppler) and the maximum image rendering resolution + and to supply paths for both Ghostscript's gs and Poppler's pdftops. + - pdftops: Allow selection whether Ghostscript or Poppler is used + at runtime, setting the "pdftops-renderer" option to "gs" or + "pdftops". + - pdftops: Allow setting an upper limit for the image rendering + resolution, also at runtime, setting the option + "pdftops-max-image-resolution-default" to the desired limit in dpi. + "0" means no limit. + - pdftops: Fixed crash by wrong usage of sizeof() function when adding + "Collate" to the fifth command line argument for the "pstops" CUPS + filter call (Ubuntu bug #982675). + - pdftops: Removed newline from copies value when reading it from + the "%%PDFTOPDFNumCopies" entry of the incoming PDF file. + - pdftops: Silenced compiler warning about ignoring the return + value of the write() function. + - pdftops: Added a crash guard. + - pdftops: Start determining the printing resolution with + cupsRasterInterpretPPD(), this is the most reliable as often + the choice names of the "Resolution" option are marketing names + with higher numerical values than the actual resolution. Also + ignore error exit values of cupsRasterInterpretPPD() as the + function can error out after having found the resolution. + - pdftops: If printing resolution is determined by + cupsRasterInterpretPPD() do not stick on 100 dpi if the + resolution cannot be determined (Ubuntu bug #984082). + CHANGES IN V1.0.17 - pdftopdf: Fixed segmentation fault when printing selected pages diff -Nru cups-filters-1.0.17/config.h.in cups-filters-1.0.18/config.h.in --- cups-filters-1.0.17/config.h.in 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/config.h.in 2012-05-16 11:02:01.000000000 +0200 @@ -113,14 +113,20 @@ /* - * Location of the poppler/Xpdf pdftops program... + * Default settings for the pdftops filter... */ -#undef HAVE_PDFTOPS -#undef HAVE_PDFTOPS_WITH_ORIGPAGESIZES -#undef HAVE_PDFTOPS_WITH_RESOLUTION -#define CUPS_PDFTOPS "/usr/bin/pdftops" +#define CUPS_PDFTOPS_RENDERER GS +#define CUPS_PDFTOPS_MAX_RESOLUTION 1440 + +/* + * Location of the poppler/Xpdf pdftops program... + */ +#undef HAVE_POPPLER_PDFTOPS +#undef HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES +#undef HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION +#define CUPS_POPPLER_PDFTOPS "/usr/bin/pdftops" /* * Location of the Ghostscript gs program... @@ -128,7 +134,7 @@ #undef HAVE_GHOSTSCRIPT #undef HAVE_GHOSTSCRIPT_PS2WRITE -#define CUPS_GHOSTSCRIPT "/usr/bin/gs" +#define CUPS_GHOSTSCRIPT "/usr/bin/gs" /* diff -Nru cups-filters-1.0.17/config-scripts/cups-common.m4 cups-filters-1.0.18/config-scripts/cups-common.m4 --- cups-filters-1.0.17/config-scripts/cups-common.m4 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/config-scripts/cups-common.m4 2012-05-16 11:02:01.000000000 +0200 @@ -20,7 +20,7 @@ AC_CONFIG_HEADER(config.h) dnl Version number information... -CUPSFILTERS_VERSION="1.0.17" +CUPSFILTERS_VERSION="1.0.18" AC_SUBST(CUPSFILTERS_VERSION) AC_DEFINE_UNQUOTED(CUPSFILTERS_SVERSION, "cups-filters v$CUPSFILTERS_VERSION") diff -Nru cups-filters-1.0.17/config-scripts/cups-pdf.m4 cups-filters-1.0.18/config-scripts/cups-pdf.m4 --- cups-filters-1.0.17/config-scripts/cups-pdf.m4 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/config-scripts/cups-pdf.m4 2012-05-16 11:02:01.000000000 +0200 @@ -13,24 +13,21 @@ dnl file is missing or damaged, see the license at "http://www.cups.org/". dnl -AC_ARG_WITH(pdftops, [ --with-pdftops set pdftops filter (gs,/path/to/gs,pdftops,/path/to/pdftops,none), default=pdftops ]) - -PDFTOPS="" -CUPS_PDFTOPS="" +AC_ARG_WITH(pdftops-renderer, [ --with-pdftops-renderer set default renderer for pdftops filter (gs,pdftops), default=gs ]) +AC_ARG_WITH(pdftops-maxres, [ --with-pdftops-maxres set default maximum image rendering resolution for pdftops filter (0, 75, 150, 300, 600, 1200, 2400, 4800, 90, 180, 360, 720, 1440, 2880, 5760, unlimited), default=1440 ]) +AC_ARG_WITH(ghostscript, [ --with-ghostscript set ghostscript path for pdftops filter (gs,/path/to/gs,none), default=gs ]) +AC_ARG_WITH(poppler-pdftops, [ --with-poppler-pdftops set Poppler pdftops path for pdftops filter (pdftops,/path/to/pdftops,none), default=pdftops ]) + +CUPS_PDFTOPS_RENDERER="" +CUPS_PDFTOPS_MAX_RESOLUTION="" +CUPS_POPPLER_PDFTOPS="" CUPS_GHOSTSCRIPT="" -case "x$with_pdftops" in +case "x$with_ghostscript" in x) # Default/auto AC_PATH_PROG(CUPS_GHOSTSCRIPT, gs) if test "x$CUPS_GHOSTSCRIPT" != x; then AC_DEFINE(HAVE_GHOSTSCRIPT) - PDFTOPS="pdftops" - else - AC_PATH_PROG(CUPS_PDFTOPS, pdftops) - if test "x$CUPS_PDFTOPS" != x; then - AC_DEFINE(HAVE_PDFTOPS) - PDFTOPS="pdftops" - fi fi ;; @@ -38,64 +35,75 @@ AC_PATH_PROG(CUPS_GHOSTSCRIPT, gs) if test "x$CUPS_GHOSTSCRIPT" != x; then AC_DEFINE(HAVE_GHOSTSCRIPT) - PDFTOPS="pdftops" else - AC_MSG_ERROR(Unable to find gs program!) - exit 1 + AC_MSG_WARN(Unable to find gs program!) fi ;; x/*/gs) # Use /path/to/gs without any check: - CUPS_GHOSTSCRIPT="$with_pdftops" + CUPS_GHOSTSCRIPT="$with_ghostscript" AC_DEFINE(HAVE_GHOSTSCRIPT) - PDFTOPS="pdftops" + ;; + + xno) # --without-ghostscript + ;; + + *) # Invalid with_ghostscript value + AC_MSG_ERROR(Invalid with-ghostscript value!) + exit 1 + ;; +esac + +case "x$with_poppler_pdftops" in + x) # Default/auto + AC_PATH_PROG(CUPS_POPPLER_PDFTOPS, pdftops) + if test "x$CUPS_POPPLER_PDFTOPS" != x; then + AC_DEFINE(HAVE_POPPLER_PDFTOPS) + fi ;; xpdftops) - AC_PATH_PROG(CUPS_PDFTOPS, pdftops) - if test "x$CUPS_PDFTOPS" != x; then - AC_DEFINE(HAVE_PDFTOPS) - PDFTOPS="pdftops" + AC_PATH_PROG(CUPS_POPPLER_PDFTOPS, pdftops) + if test "x$CUPS_POPPLER_PDFTOPS" != x; then + AC_DEFINE(HAVE_POPPLER_PDFTOPS) else - AC_MSG_ERROR(Unable to find pdftops program!) - exit 1 + AC_MSG_WARN(Unable to find Poppler pdftops program!) fi ;; x/*/pdftops) # Use /path/to/pdftops without any check: - CUPS_PDFTOPS="$with_pdftops" - AC_DEFINE(HAVE_PDFTOPS) - PDFTOPS="pdftops" + CUPS_POPPLER_PDFTOPS="$with_poppler_pdftops" + AC_DEFINE(HAVE_POPPLER_PDFTOPS) ;; - xnone) # Make no pdftops filter if with_pdftops=none: + xno) # --without-poppler-pdftops ;; - *) # Invalid with_pdftops value: - AC_MSG_ERROR(Invalid with_pdftops value!) + *) # Invalid with_poppler-pdftops value + echo "$with_poppler_pdftops" + AC_MSG_ERROR(Invalid with-poppler-pdftops value!) exit 1 ;; esac -if test "x$CUPS_PDFTOPS" != x; then - AC_MSG_CHECKING(whether pdftops supports -origpagesizes) - if ($CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes); then +if test "x$CUPS_POPPLER_PDFTOPS" != x; then + AC_MSG_CHECKING(whether Poppler pdftops supports -origpagesizes) + if ($CUPS_POPPLER_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes); then AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PDFTOPS_WITH_ORIGPAGESIZES) + AC_DEFINE(HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES) else AC_MSG_RESULT(no) fi - AC_MSG_CHECKING(whether pdftops supports -r) - if ($CUPS_PDFTOPS -h 2>&1 | grep -q -- '-r '); then + AC_MSG_CHECKING(whether Poppler pdftops supports -r) + if ($CUPS_POPPLER_PDFTOPS -h 2>&1 | grep -q -- '-r '); then AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PDFTOPS_WITH_RESOLUTION) + AC_DEFINE(HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION) else AC_MSG_RESULT(no) fi - - DEFAULT_PDFTOPS="" -elif test "x$CUPS_GHOSTSCRIPT" != x; then +fi +if test "x$CUPS_GHOSTSCRIPT" != x; then AC_MSG_CHECKING(whether gs supports the ps2write device) if ($CUPS_GHOSTSCRIPT -h 2>&1 | grep -q ps2write); then AC_MSG_RESULT(yes) @@ -103,16 +111,53 @@ else AC_MSG_RESULT(no) fi - - DEFAULT_PDFTOPS="" -else - DEFAULT_PDFTOPS="#" fi +case "x$with_pdftops_renderer" in + x|xgs) # gs + CUPS_PDFTOPS_RENDERER=GS + if test "x$CUPS_GHOSTSCRIPT" = x; then + AC_MSG_WARN(Default renderer Ghostscript is not available!) + fi + ;; + + xpdftops) # pdftops + CUPS_PDFTOPS_RENDERER=PDFTOPS + if test "x$CUPS_POPPLER_PDFTOPS" = x; then + AC_MSG_WARN(Default renderer Poppler pdftops is not available!) + fi + ;; + + *) # Invalid with_pdftops-renderer value + AC_MSG_ERROR(Invalid with-pdftops-renderer value!) + exit 1 + ;; +esac + +case "x$with_pdftops_maxres" in + + x) + CUPS_PDFTOPS_MAXRES=1440 + ;; + + x75|x150|x300|x600|x1200|x2400|x4800|x90|x180|x360|x720|x1440|x2880|x5760) + CUPS_PDFTOPS_MAXRES=$with_pdftops_maxres + ;; + + x0|xunlimited|xno) + CUPS_PDFTOPS_MAXRES=0 + ;; + + *) # Invalid with_pdftops-renderer value + AC_MSG_ERROR(Invalid with-pdftops-maxres value!) + exit 1 + ;; +esac + +AC_DEFINE_UNQUOTED(CUPS_PDFTOPS_RENDERER, $CUPS_PDFTOPS_RENDERER) +AC_DEFINE_UNQUOTED(CUPS_PDFTOPS_MAX_RESOLUTION, $CUPS_PDFTOPS_MAXRES) AC_DEFINE_UNQUOTED(CUPS_PDFTOPS, "$CUPS_PDFTOPS") AC_DEFINE_UNQUOTED(CUPS_GHOSTSCRIPT, "$CUPS_GHOSTSCRIPT") -AC_SUBST(DEFAULT_PDFTOPS) -AC_SUBST(PDFTOPS) dnl dnl End of "$Id$". diff -Nru cups-filters-1.0.17/configure cups-filters-1.0.18/configure --- cups-filters-1.0.17/configure 2012-04-20 14:30:04.000000000 +0200 +++ cups-filters-1.0.18/configure 2012-05-16 11:02:02.000000000 +0200 @@ -596,9 +596,7 @@ LIBOBJS PHPDIR PHPCONFIG -PDFTOPS -DEFAULT_PDFTOPS -CUPS_PDFTOPS +CUPS_POPPLER_PDFTOPS CUPS_GHOSTSCRIPT FONTCONFIG_LIBS FONTCONFIG_CFLAGS @@ -727,7 +725,10 @@ with_poppler_source enable_zlib enable_libjpeg -with_pdftops +with_pdftops_renderer +with_pdftops_maxres +with_ghostscript +with_poppler_pdftops with_php ' ac_precious_vars='build_alias @@ -1377,7 +1378,10 @@ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-optim set optimization flags --with-poppler-source=PATH poppler source directory path - --with-pdftops set pdftops filter (gs,/path/to/gs,pdftops,/path/to/pdftops,none), default=pdftops + --with-pdftops-renderer set default renderer for pdftops filter (gs,pdftops), default=gs + --with-pdftops-maxres set default maximum image rendering resolution for pdftops filter (0, 75, 150, 300, 600, 1200, 2400, 4800, 90, 180, 360, 720, 1440, 2880, 5760, unlimited), default=1440 + --with-ghostscript set ghostscript path for pdftops filter (gs,/path/to/gs,none), default=gs + --with-poppler-pdftops set Poppler pdftops path for pdftops filter (pdftops,/path/to/pdftops,none), default=pdftops --with-php set PHP interpreter for web interfaces Some influential environment variables: @@ -2415,7 +2419,7 @@ ac_config_headers="$ac_config_headers config.h" -CUPSFILTERS_VERSION="1.0.17" +CUPSFILTERS_VERSION="1.0.18" cat >>confdefs.h <<_ACEOF #define CUPSFILTERS_SVERSION "cups-filters v$CUPSFILTERS_VERSION" @@ -6992,17 +6996,36 @@ -# Check whether --with-pdftops was given. -if test "${with_pdftops+set}" = set; then : - withval=$with_pdftops; +# Check whether --with-pdftops-renderer was given. +if test "${with_pdftops_renderer+set}" = set; then : + withval=$with_pdftops_renderer; fi -PDFTOPS="" -CUPS_PDFTOPS="" +# Check whether --with-pdftops-maxres was given. +if test "${with_pdftops_maxres+set}" = set; then : + withval=$with_pdftops_maxres; +fi + + +# Check whether --with-ghostscript was given. +if test "${with_ghostscript+set}" = set; then : + withval=$with_ghostscript; +fi + + +# Check whether --with-poppler-pdftops was given. +if test "${with_poppler_pdftops+set}" = set; then : + withval=$with_poppler_pdftops; +fi + + +CUPS_PDFTOPS_RENDERER="" +CUPS_PDFTOPS_MAX_RESOLUTION="" +CUPS_POPPLER_PDFTOPS="" CUPS_GHOSTSCRIPT="" -case "x$with_pdftops" in +case "x$with_ghostscript" in x) # Default/auto # Extract the first word of "gs", so it can be a program name with args. set dummy gs; ac_word=$2 @@ -7047,18 +7070,20 @@ if test "x$CUPS_GHOSTSCRIPT" != x; then $as_echo "#define HAVE_GHOSTSCRIPT 1" >>confdefs.h - PDFTOPS="pdftops" - else - # Extract the first word of "pdftops", so it can be a program name with args. -set dummy pdftops; ac_word=$2 + fi + ;; + + xgs) + # Extract the first word of "gs", so it can be a program name with args. +set dummy gs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CUPS_PDFTOPS+set}" = set; then : +if test "${ac_cv_path_CUPS_GHOSTSCRIPT+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $CUPS_PDFTOPS in + case $CUPS_GHOSTSCRIPT in [\\/]* | ?:[\\/]*) - ac_cv_path_CUPS_PDFTOPS="$CUPS_PDFTOPS" # Let the user override the test with a path. + ac_cv_path_CUPS_GHOSTSCRIPT="$CUPS_GHOSTSCRIPT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -7068,7 +7093,7 @@ test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_CUPS_PDFTOPS="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_CUPS_GHOSTSCRIPT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -7079,35 +7104,52 @@ ;; esac fi -CUPS_PDFTOPS=$ac_cv_path_CUPS_PDFTOPS -if test -n "$CUPS_PDFTOPS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_PDFTOPS" >&5 -$as_echo "$CUPS_PDFTOPS" >&6; } +CUPS_GHOSTSCRIPT=$ac_cv_path_CUPS_GHOSTSCRIPT +if test -n "$CUPS_GHOSTSCRIPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_GHOSTSCRIPT" >&5 +$as_echo "$CUPS_GHOSTSCRIPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$CUPS_PDFTOPS" != x; then - $as_echo "#define HAVE_PDFTOPS 1" >>confdefs.h + if test "x$CUPS_GHOSTSCRIPT" != x; then + $as_echo "#define HAVE_GHOSTSCRIPT 1" >>confdefs.h - PDFTOPS="pdftops" - fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to find gs program!" >&5 +$as_echo "$as_me: WARNING: Unable to find gs program!" >&2;} fi ;; - xgs) - # Extract the first word of "gs", so it can be a program name with args. -set dummy gs; ac_word=$2 + x/*/gs) # Use /path/to/gs without any check: + CUPS_GHOSTSCRIPT="$with_ghostscript" + $as_echo "#define HAVE_GHOSTSCRIPT 1" >>confdefs.h + + ;; + + xno) # --without-ghostscript + ;; + + *) # Invalid with_ghostscript value + as_fn_error "Invalid with-ghostscript value!" "$LINENO" 5 + exit 1 + ;; +esac + +case "x$with_poppler_pdftops" in + x) # Default/auto + # Extract the first word of "pdftops", so it can be a program name with args. +set dummy pdftops; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CUPS_GHOSTSCRIPT+set}" = set; then : +if test "${ac_cv_path_CUPS_POPPLER_PDFTOPS+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $CUPS_GHOSTSCRIPT in + case $CUPS_POPPLER_PDFTOPS in [\\/]* | ?:[\\/]*) - ac_cv_path_CUPS_GHOSTSCRIPT="$CUPS_GHOSTSCRIPT" # Let the user override the test with a path. + ac_cv_path_CUPS_POPPLER_PDFTOPS="$CUPS_POPPLER_PDFTOPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -7117,7 +7159,7 @@ test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_CUPS_GHOSTSCRIPT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_CUPS_POPPLER_PDFTOPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -7128,44 +7170,33 @@ ;; esac fi -CUPS_GHOSTSCRIPT=$ac_cv_path_CUPS_GHOSTSCRIPT -if test -n "$CUPS_GHOSTSCRIPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_GHOSTSCRIPT" >&5 -$as_echo "$CUPS_GHOSTSCRIPT" >&6; } +CUPS_POPPLER_PDFTOPS=$ac_cv_path_CUPS_POPPLER_PDFTOPS +if test -n "$CUPS_POPPLER_PDFTOPS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_POPPLER_PDFTOPS" >&5 +$as_echo "$CUPS_POPPLER_PDFTOPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$CUPS_GHOSTSCRIPT" != x; then - $as_echo "#define HAVE_GHOSTSCRIPT 1" >>confdefs.h + if test "x$CUPS_POPPLER_PDFTOPS" != x; then + $as_echo "#define HAVE_POPPLER_PDFTOPS 1" >>confdefs.h - PDFTOPS="pdftops" - else - as_fn_error "Unable to find gs program!" "$LINENO" 5 - exit 1 fi ;; - x/*/gs) # Use /path/to/gs without any check: - CUPS_GHOSTSCRIPT="$with_pdftops" - $as_echo "#define HAVE_GHOSTSCRIPT 1" >>confdefs.h - - PDFTOPS="pdftops" - ;; - xpdftops) # Extract the first word of "pdftops", so it can be a program name with args. set dummy pdftops; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CUPS_PDFTOPS+set}" = set; then : +if test "${ac_cv_path_CUPS_POPPLER_PDFTOPS+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $CUPS_PDFTOPS in + case $CUPS_POPPLER_PDFTOPS in [\\/]* | ?:[\\/]*) - ac_cv_path_CUPS_PDFTOPS="$CUPS_PDFTOPS" # Let the user override the test with a path. + ac_cv_path_CUPS_POPPLER_PDFTOPS="$CUPS_POPPLER_PDFTOPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -7175,7 +7206,7 @@ test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_CUPS_PDFTOPS="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_CUPS_POPPLER_PDFTOPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -7186,69 +7217,67 @@ ;; esac fi -CUPS_PDFTOPS=$ac_cv_path_CUPS_PDFTOPS -if test -n "$CUPS_PDFTOPS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_PDFTOPS" >&5 -$as_echo "$CUPS_PDFTOPS" >&6; } +CUPS_POPPLER_PDFTOPS=$ac_cv_path_CUPS_POPPLER_PDFTOPS +if test -n "$CUPS_POPPLER_PDFTOPS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_POPPLER_PDFTOPS" >&5 +$as_echo "$CUPS_POPPLER_PDFTOPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$CUPS_PDFTOPS" != x; then - $as_echo "#define HAVE_PDFTOPS 1" >>confdefs.h + if test "x$CUPS_POPPLER_PDFTOPS" != x; then + $as_echo "#define HAVE_POPPLER_PDFTOPS 1" >>confdefs.h - PDFTOPS="pdftops" else - as_fn_error "Unable to find pdftops program!" "$LINENO" 5 - exit 1 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to find Poppler pdftops program!" >&5 +$as_echo "$as_me: WARNING: Unable to find Poppler pdftops program!" >&2;} fi ;; x/*/pdftops) # Use /path/to/pdftops without any check: - CUPS_PDFTOPS="$with_pdftops" - $as_echo "#define HAVE_PDFTOPS 1" >>confdefs.h + CUPS_POPPLER_PDFTOPS="$with_poppler_pdftops" + $as_echo "#define HAVE_POPPLER_PDFTOPS 1" >>confdefs.h - PDFTOPS="pdftops" ;; - xnone) # Make no pdftops filter if with_pdftops=none: + xno) # --without-poppler-pdftops ;; - *) # Invalid with_pdftops value: - as_fn_error "Invalid with_pdftops value!" "$LINENO" 5 + *) # Invalid with_poppler-pdftops value + echo "$with_poppler_pdftops" + as_fn_error "Invalid with-poppler-pdftops value!" "$LINENO" 5 exit 1 ;; esac -if test "x$CUPS_PDFTOPS" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pdftops supports -origpagesizes" >&5 -$as_echo_n "checking whether pdftops supports -origpagesizes... " >&6; } - if ($CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes); then +if test "x$CUPS_POPPLER_PDFTOPS" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Poppler pdftops supports -origpagesizes" >&5 +$as_echo_n "checking whether Poppler pdftops supports -origpagesizes... " >&6; } + if ($CUPS_POPPLER_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes); then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - $as_echo "#define HAVE_PDFTOPS_WITH_ORIGPAGESIZES 1" >>confdefs.h + $as_echo "#define HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pdftops supports -r" >&5 -$as_echo_n "checking whether pdftops supports -r... " >&6; } - if ($CUPS_PDFTOPS -h 2>&1 | grep -q -- '-r '); then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Poppler pdftops supports -r" >&5 +$as_echo_n "checking whether Poppler pdftops supports -r... " >&6; } + if ($CUPS_POPPLER_PDFTOPS -h 2>&1 | grep -q -- '-r '); then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - $as_echo "#define HAVE_PDFTOPS_WITH_RESOLUTION 1" >>confdefs.h + $as_echo "#define HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - - DEFAULT_PDFTOPS="" -elif test "x$CUPS_GHOSTSCRIPT" != x; then +fi +if test "x$CUPS_GHOSTSCRIPT" != x; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gs supports the ps2write device" >&5 $as_echo_n "checking whether gs supports the ps2write device... " >&6; } if ($CUPS_GHOSTSCRIPT -h 2>&1 | grep -q ps2write); then @@ -7260,21 +7289,66 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - - DEFAULT_PDFTOPS="" -else - DEFAULT_PDFTOPS="#" fi +case "x$with_pdftops_renderer" in + x|xgs) # gs + CUPS_PDFTOPS_RENDERER=GS + if test "x$CUPS_GHOSTSCRIPT" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Default renderer Ghostscript is not available!" >&5 +$as_echo "$as_me: WARNING: Default renderer Ghostscript is not available!" >&2;} + fi + ;; + + xpdftops) # pdftops + CUPS_PDFTOPS_RENDERER=PDFTOPS + if test "x$CUPS_POPPLER_PDFTOPS" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Default renderer Poppler pdftops is not available!" >&5 +$as_echo "$as_me: WARNING: Default renderer Poppler pdftops is not available!" >&2;} + fi + ;; + + *) # Invalid with_pdftops-renderer value + as_fn_error "Invalid with-pdftops-renderer value!" "$LINENO" 5 + exit 1 + ;; +esac + +case "x$with_pdftops_maxres" in + + x) + CUPS_PDFTOPS_MAXRES=1440 + ;; + + x75|x150|x300|x600|x1200|x2400|x4800|x90|x180|x360|x720|x1440|x2880|x5760) + CUPS_PDFTOPS_MAXRES=$with_pdftops_maxres + ;; + + x0|xunlimited|xno) + CUPS_PDFTOPS_MAXRES=0 + ;; + + *) # Invalid with_pdftops-renderer value + as_fn_error "Invalid with-pdftops-maxres value!" "$LINENO" 5 + exit 1 + ;; +esac + cat >>confdefs.h <<_ACEOF -#define CUPS_PDFTOPS "$CUPS_PDFTOPS" +#define CUPS_PDFTOPS_RENDERER $CUPS_PDFTOPS_RENDERER _ACEOF cat >>confdefs.h <<_ACEOF -#define CUPS_GHOSTSCRIPT "$CUPS_GHOSTSCRIPT" +#define CUPS_PDFTOPS_MAX_RESOLUTION $CUPS_PDFTOPS_MAXRES _ACEOF +cat >>confdefs.h <<_ACEOF +#define CUPS_PDFTOPS "$CUPS_PDFTOPS" +_ACEOF +cat >>confdefs.h <<_ACEOF +#define CUPS_GHOSTSCRIPT "$CUPS_GHOSTSCRIPT" +_ACEOF diff -Nru cups-filters-1.0.17/debian/changelog cups-filters-1.0.18/debian/changelog --- cups-filters-1.0.17/debian/changelog 2012-04-20 14:49:59.000000000 +0200 +++ cups-filters-1.0.18/debian/changelog 2012-05-16 12:29:59.000000000 +0200 @@ -1,3 +1,48 @@ +cups-filters (1.0.18-0ubuntu0.1) precise-proposed; urgency=low + + [ Till Kamppeter ] + * New upstream release + - pdftops: Allow selection whether Ghostscript or Poppler is used + at runtime, setting the "pdftops-renderer" option to "gs" or + "pdftops". This way one can switch to Poppler per-queue if there + are incompatibilities with certain PostScript printers. + - pdftops: Allow setting an upper limit for the image rendering + resolution, also at runtime, setting the option + "pdftops-max-image-resolution-default" to the desired limit in dpi. + "0" means no limit. + - pdftops: Fixed crash by wrong usage of sizeof() function when adding + "Collate" to the fifth command line argument for the "pstops" CUPS + filter call (LP: #982675). + - pdftops: Removed newline from copies value when reading it from + the "%%PDFTOPDFNumCopies" entry of the incoming PDF file. + - pdftops: Silenced compiler warning about ignoring the return + value of the write() function. + - pdftops: Added a crash guard. + - pdftops: Start determining the printing resolution with + cupsRasterInterpretPPD(), this is the most reliable as often + the choice names of the "Resolution" option are marketing names + with higher numerical values than the actual resolution. Also + ignore error exit values of cupsRasterInterpretPPD() as the + function can error out after having found the resolution + (LP: #984082). + - pdftops: If printing resolution is determined by + cupsRasterInterpretPPD() do not stick on 100 dpi if the + resolution cannot be determined (LP: #984082). + * debian/rules: Set default renderer for the pdftops filter to Poppler + due to many printer's buggy interpreters having problems with GhostScript's + PostScript and set image rendering resolution limit of the pdftops filter + to 360 dpi to prevents slow processing by the printer if very high + resolutions are used or if the printing resolution is mis-detected by the + pdftops filter (LP: #668800, LP #951627 (comment #30), LP: #998087, + LP: #992982 (comments #26, #27, #30, #31), LP: #997728, LP: #994477, + LP: #998087, LP: #978120, LP: #862167). + + [ Didier Raboud ] + * Drop libtiff5-dev, just use libtiff-dev, this fixes the FTBFS due to + incompatibility with cups. + + -- Till Kamppeter Wed, 16 May 2012 11:25:03 +0200 + cups-filters (1.0.17-0bzr0.1) precise-proposed; urgency=low * New upstream release diff -Nru cups-filters-1.0.17/debian/control cups-filters-1.0.18/debian/control --- cups-filters-1.0.17/debian/control 2012-04-20 14:40:42.000000000 +0200 +++ cups-filters-1.0.18/debian/control 2012-05-16 11:27:47.000000000 +0200 @@ -21,7 +21,7 @@ libpoppler-private-dev (>= 0.16.0), libjpeg-dev, libpng-dev | libpng12-dev, - libtiff5-dev | libtiff-dev, + libtiff-dev, libcups2-dev, libcupsimage2-dev (>= 1.5.2-6~), libijs-dev, diff -Nru cups-filters-1.0.17/debian/rules cups-filters-1.0.18/debian/rules --- cups-filters-1.0.17/debian/rules 2012-04-20 14:40:42.000000000 +0200 +++ cups-filters-1.0.18/debian/rules 2012-05-16 12:23:52.000000000 +0200 @@ -16,7 +16,7 @@ include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/autotools.mk -DEB_CONFIGURE_EXTRA_FLAGS := --with-optim=$(DEB_OPTFLAGS) --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) --mandir=/usr/share/man --enable-static --enable-debug +DEB_CONFIGURE_EXTRA_FLAGS := --with-optim=$(DEB_OPTFLAGS) --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) --mandir=/usr/share/man --enable-static --enable-debug --with-pdftops-renderer=pdftops --with-pdftops-maxres=360 DEB_MAKE_INSTALL_TARGET := install BUILDROOT=$(DEB_DESTDIR) DEB_INSTALL_CHANGELOGS_ALL := CHANGES.txt diff -Nru cups-filters-1.0.17/filter/pdftops.c cups-filters-1.0.18/filter/pdftops.c --- cups-filters-1.0.17/filter/pdftops.c 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/filter/pdftops.c 2012-05-16 11:02:01.000000000 +0200 @@ -37,6 +37,13 @@ #define MAX_CHECK_COMMENT_LINES 20 /* + * Type definitions + */ + +typedef unsigned renderer_t; +enum renderer_e {GS = 0, PDFTOPS = 1}; + +/* * Local functions... */ @@ -49,7 +56,7 @@ static int job_canceled = 0; int pdftopdfapplied = 0; -char *deviceCopies = "1"; +char deviceCopies[32] = "1"; int deviceCollate = 0; @@ -129,7 +136,11 @@ p = strchr(buf+19,':') + 1; while (*p == ' ' || *p == '\t') p++; - deviceCopies = strdup(p); + strncpy(deviceCopies, p, sizeof(deviceCopies)); + deviceCopies[sizeof(deviceCopies) - 1] = '\0'; + p = deviceCopies + strlen(deviceCopies) - 1; + while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') p--; + *(p + 1) = '\0'; pdftopdfapplied = 1; } else if (strncmp(buf,"%%PDFTOPDFCollate",17) == 0) { char *p; @@ -202,6 +213,7 @@ main(int argc, /* I - Number of command-line args */ char *argv[]) /* I - Command-line arguments */ { + renderer_t renderer = CUPS_PDFTOPS_RENDERER; /* Renderer: gs or pdftops */ int fd; /* Copy file descriptor */ char *filename, /* PDF file to convert */ tempfile[1024]; /* Temporary file */ @@ -216,6 +228,8 @@ ppd_size_t *size; /* Current page size */ char resolution[128] = "300";/* Output resolution */ int xres = 0, yres = 0, /* resolution values */ + maxres = CUPS_PDFTOPS_MAX_RESOLUTION, + /* Maximum image rendering resolution */ numvalues; /* Number of values actually read */ ppd_choice_t *choice; ppd_attr_t *attr; @@ -304,7 +318,7 @@ tempfile); while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) - write(fd, buffer, bytes); + bytes = write(fd, buffer, bytes); close(fd); @@ -337,6 +351,21 @@ cupsMarkOptions(ppd, num_options, options); /* + * Select the PDF renderer: Ghostscript (gs) or Poppler (pdftops) + */ + + if ((val = cupsGetOption("pdftops-renderer", num_options, options)) != NULL) + { + if (strcasecmp(val, "gs") == 0) + renderer = GS; + else if (strcasecmp(val, "pdftops") == 0) + renderer = PDFTOPS; + else + fprintf(stderr, + "WARNING: Invalid value for \"pdftops-renderer\": \"%s\"\n", val); + } + + /* * Build the pstops command-line... */ @@ -362,7 +391,7 @@ * printer does hardware collate. */ - pstops_options = realloc(pstops_options, sizeof(pstops_options) + 8); + pstops_options = realloc(pstops_options, strlen(pstops_options) + 9); pstops_end = pstops_options + strlen(pstops_options); strcpy(pstops_end, " Collate"); } @@ -382,23 +411,26 @@ * Build the command-line for the pdftops or gs filter... */ -#ifdef HAVE_PDFTOPS - pdf_argv[0] = (char *)"pdftops"; - pdf_argc = 1; -#else - pdf_argv[0] = (char *)"gs"; - pdf_argv[1] = (char *)"-q"; - pdf_argv[2] = (char *)"-dNOPAUSE"; - pdf_argv[3] = (char *)"-dBATCH"; - pdf_argv[4] = (char *)"-dSAFER"; -# ifdef HAVE_GHOSTSCRIPT_PS2WRITE - pdf_argv[5] = (char *)"-sDEVICE=ps2write"; -# else - pdf_argv[5] = (char *)"-sDEVICE=pswrite"; -# endif /* HAVE_GHOSTSCRIPT_PS2WRITE */ - pdf_argv[6] = (char *)"-sOUTPUTFILE=%stdout"; - pdf_argc = 7; -#endif /* HAVE_PDFTOPS */ + if (renderer == PDFTOPS) + { + pdf_argv[0] = (char *)"pdftops"; + pdf_argc = 1; + } + else + { + pdf_argv[0] = (char *)"gs"; + pdf_argv[1] = (char *)"-q"; + pdf_argv[2] = (char *)"-dNOPAUSE"; + pdf_argv[3] = (char *)"-dBATCH"; + pdf_argv[4] = (char *)"-dSAFER"; +# ifdef HAVE_GHOSTSCRIPT_PS2WRITE + pdf_argv[5] = (char *)"-sDEVICE=ps2write"; +# else + pdf_argv[5] = (char *)"-sDEVICE=pswrite"; +# endif /* HAVE_GHOSTSCRIPT_PS2WRITE */ + pdf_argv[6] = (char *)"-sOUTPUTFILE=%stdout"; + pdf_argc = 7; + } if (ppd) { @@ -408,31 +440,34 @@ if (ppd->language_level == 1) { -#ifdef HAVE_PDFTOPS - pdf_argv[pdf_argc++] = (char *)"-level1"; - pdf_argv[pdf_argc++] = (char *)"-noembtt"; -#else - pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=1"; -#endif /* HAVE_PDFTOPS */ + if (renderer == PDFTOPS) + { + pdf_argv[pdf_argc++] = (char *)"-level1"; + pdf_argv[pdf_argc++] = (char *)"-noembtt"; + } + else + pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=1"; } else if (ppd->language_level == 2) { -#ifdef HAVE_PDFTOPS - pdf_argv[pdf_argc++] = (char *)"-level2"; - if (!ppd->ttrasterizer) - pdf_argv[pdf_argc++] = (char *)"-noembtt"; -#else - pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=2"; -#endif /* HAVE_PDFTOPS */ + if (renderer == PDFTOPS) + { + pdf_argv[pdf_argc++] = (char *)"-level2"; + if (!ppd->ttrasterizer) + pdf_argv[pdf_argc++] = (char *)"-noembtt"; + } + else + pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=2"; } else -#ifdef HAVE_PDFTOPS - /* Do not emit PS Level 3 with Poppler, some HP PostScript printers - do not like it. See https://bugs.launchpad.net/bugs/277404. */ - pdf_argv[pdf_argc++] = (char *)"-level2"; -#else - pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=3"; -#endif /* HAVE_PDFTOPS */ + { + if (renderer == PDFTOPS) + /* Do not emit PS Level 3 with Poppler, some HP PostScript printers + do not like it. See https://bugs.launchpad.net/bugs/277404. */ + pdf_argv[pdf_argc++] = (char *)"-level2"; + else + pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=3"; + } if ((val = cupsGetOption("fitplot", num_options, options)) == NULL) val = cupsGetOption("fit-to-page", num_options, options); @@ -479,46 +514,49 @@ orientation ^= 1; } -#ifdef HAVE_PDFTOPS - if (orientation & 1) - { - snprintf(pdf_width, sizeof(pdf_width), "%.0f", size->length); - snprintf(pdf_height, sizeof(pdf_height), "%.0f", size->width); - } - else + if (renderer == PDFTOPS) { - snprintf(pdf_width, sizeof(pdf_width), "%.0f", size->width); - snprintf(pdf_height, sizeof(pdf_height), "%.0f", size->length); - } + if (orientation & 1) + { + snprintf(pdf_width, sizeof(pdf_width), "%.0f", size->length); + snprintf(pdf_height, sizeof(pdf_height), "%.0f", size->width); + } + else + { + snprintf(pdf_width, sizeof(pdf_width), "%.0f", size->width); + snprintf(pdf_height, sizeof(pdf_height), "%.0f", size->length); + } - pdf_argv[pdf_argc++] = (char *)"-paperw"; - pdf_argv[pdf_argc++] = pdf_width; - pdf_argv[pdf_argc++] = (char *)"-paperh"; - pdf_argv[pdf_argc++] = pdf_height; - pdf_argv[pdf_argc++] = (char *)"-expand"; + pdf_argv[pdf_argc++] = (char *)"-paperw"; + pdf_argv[pdf_argc++] = pdf_width; + pdf_argv[pdf_argc++] = (char *)"-paperh"; + pdf_argv[pdf_argc++] = pdf_height; + pdf_argv[pdf_argc++] = (char *)"-expand"; -#else - if (orientation & 1) - { - snprintf(pdf_width, sizeof(pdf_width), "-dDEVICEWIDTHPOINTS=%.0f", - size->length); - snprintf(pdf_height, sizeof(pdf_height), "-dDEVICEHEIGHTPOINTS=%.0f", - size->width); } else { - snprintf(pdf_width, sizeof(pdf_width), "-dDEVICEWIDTHPOINTS=%.0f", - size->width); - snprintf(pdf_height, sizeof(pdf_height), "-dDEVICEHEIGHTPOINTS=%.0f", - size->length); - } + if (orientation & 1) + { + snprintf(pdf_width, sizeof(pdf_width), "-dDEVICEWIDTHPOINTS=%.0f", + size->length); + snprintf(pdf_height, sizeof(pdf_height), "-dDEVICEHEIGHTPOINTS=%.0f", + size->width); + } + else + { + snprintf(pdf_width, sizeof(pdf_width), "-dDEVICEWIDTHPOINTS=%.0f", + size->width); + snprintf(pdf_height, sizeof(pdf_height), "-dDEVICEHEIGHTPOINTS=%.0f", + size->length); + } - pdf_argv[pdf_argc++] = pdf_width; - pdf_argv[pdf_argc++] = pdf_height; -#endif /* HAVE_PDFTOPS */ + pdf_argv[pdf_argc++] = pdf_width; + pdf_argv[pdf_argc++] = pdf_height; + } } -#if defined(HAVE_PDFTOPS) && defined(HAVE_PDFTOPS_WITH_ORIGPAGESIZES) - else +#ifdef HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES + else if (renderer == PDFTOPS) { /* * Use the page sizes of the original PDF document, this way documents @@ -527,23 +565,29 @@ pdf_argv[pdf_argc++] = (char *)"-origpagesizes"; } -#endif /* HAVE_PDFTOPS && HAVE_PDFTOPS_WITH_ORIGPAGESIZES */ +#endif /* HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES */ /* * Set output resolution ... */ - if ((choice = ppdFindMarkedChoice(ppd, "Resolution")) != NULL) + /* Ignore error exits of cupsRasterInterpretPPD(), if it found a resolution + setting before erroring it is OK for us */ + cupsRasterInterpretPPD(&header, ppd, num_options, options, NULL); + /* 100 dpi is default, this means that if we have 100 dpi here this + method failed to find the printing resolution */ + if (header.HWResolution[0] > 100 && header.HWResolution[1] > 100) + { + xres = header.HWResolution[0]; + yres = header.HWResolution[1]; + } + else if ((choice = ppdFindMarkedChoice(ppd, "Resolution")) != NULL) strncpy(resolution, choice->choice, sizeof(resolution)); else if ((attr = ppdFindAttr(ppd,"DefaultResolution",NULL)) != NULL) strncpy(resolution, attr->value, sizeof(resolution)); - else if (cupsRasterInterpretPPD(&header, ppd, num_options, options, NULL) == 0) - { - xres = header.HWResolution[0]; - yres = header.HWResolution[1]; - } } + resolution[sizeof(resolution)-1] = '\0'; if ((xres > 0) || (yres > 0) || ((numvalues = sscanf(resolution, "%dx%d", &xres, &yres)) > 0)) { @@ -553,80 +597,90 @@ xres = 300; /* - * Reduce the image rendering resolution to make processing of jobs by poth - * the PDF->PS converter and the printer faster + * Get the ceiling for the image rendering resolution */ - /* - if (xres % 90 == 0) - { - if (xres > 360) - xres = max(360, xres / 2); - } - else if (xres % 75 == 0) + + if ((val = cupsGetOption("pdftops-max-image-resolution", num_options, options)) != NULL) { - if (xres > 300) - xres = max(300, xres / 2); + if ((numvalues = sscanf(val, "%d", &yres)) > 0) + maxres = yres; + else + fprintf(stderr, + "WARNING: Invalid value for \"pdftops-max-image-resolution\": \"%s\"\n", val); } - */ -#ifdef HAVE_PDFTOPS -#ifdef HAVE_PDFTOPS_WITH_RESOLUTION - /* - * Set resolution to avoid slow processing by the printer when the resolution - * of embedded images does not match the printer' s resolution - */ - pdf_argv[pdf_argc++] = (char *)"-r"; - snprintf(resolution, sizeof(resolution), "%d", xres); - pdf_argv[pdf_argc++] = resolution; - fprintf(stderr, "DEBUG: Using image rendering resolution %d dpi\n", xres); -#endif /* HAVE_PDFTOPS_WITH_RESOLUTION */ - pdf_argv[pdf_argc++] = filename; - pdf_argv[pdf_argc++] = (char *)"-"; -#else /* - * Set resolution to avoid slow processing by the printer when the resolution - * of embedded images does not match the printer' s resolution + * Reduce the image rendering resolution to not exceed a given maximum + * to make processing of jobs by the PDF->PS converter and the printer faster + * + * maxres = 0 means no limit */ - snprintf(resolution, 127, "-r%d", xres); - pdf_argv[pdf_argc++] = resolution; - fprintf(stderr, "DEBUG: Using image rendering resolution %d dpi\n", xres); - /* - * PostScript debug mode: If you send a job with "lpr -o psdebug" Ghostscript - * will not compress the pages, so that the PostScript code can get - * analysed. This is especially important if a PostScript printer errors or - * misbehaves on Ghostscript's output. - * On Kyocera printers we always suppress page compression, to avoid slow - * processing of raster images. - */ - val = cupsGetOption("psdebug", num_options, options); - if ((val && strcasecmp(val, "no") && strcasecmp(val, "off") && - strcasecmp(val, "false")) || - (ppd && ppd->manufacturer && - !strncasecmp(ppd->manufacturer, "Kyocera", 7))) + + if (maxres) + while (xres > maxres) + xres = xres / 2; + + if (renderer == PDFTOPS) { - fprintf(stderr, "DEBUG: Deactivated compression of pages in Ghostscript's PostScript output (\"psdebug\" debug mode or Kyocera printer)\n"); - pdf_argv[pdf_argc++] = (char *)"-dCompressPages=false"; +#ifdef HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION + /* + * Set resolution to avoid slow processing by the printer when the + * resolution of embedded images does not match the printer's resolution + */ + pdf_argv[pdf_argc++] = (char *)"-r"; + snprintf(resolution, sizeof(resolution), "%d", xres); + pdf_argv[pdf_argc++] = resolution; + fprintf(stderr, "DEBUG: Using image rendering resolution %d dpi\n", xres); +#endif /* HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION */ + pdf_argv[pdf_argc++] = filename; + pdf_argv[pdf_argc++] = (char *)"-"; + } + else + { + /* + * Set resolution to avoid slow processing by the printer when the + * resolution of embedded images does not match the printer's resolution + */ + snprintf(resolution, 127, "-r%d", xres); + pdf_argv[pdf_argc++] = resolution; + fprintf(stderr, "DEBUG: Using image rendering resolution %d dpi\n", xres); + /* + * PostScript debug mode: If you send a job with "lpr -o psdebug" Ghostscript + * will not compress the pages, so that the PostScript code can get + * analysed. This is especially important if a PostScript printer errors or + * misbehaves on Ghostscript's output. + * On Kyocera printers we always suppress page compression, to avoid slow + * processing of raster images. + */ + val = cupsGetOption("psdebug", num_options, options); + if ((val && strcasecmp(val, "no") && strcasecmp(val, "off") && + strcasecmp(val, "false")) || + (ppd && ppd->manufacturer && + !strncasecmp(ppd->manufacturer, "Kyocera", 7))) + { + fprintf(stderr, "DEBUG: Deactivated compression of pages in Ghostscript's PostScript output (\"psdebug\" debug mode or Kyocera printer)\n"); + pdf_argv[pdf_argc++] = (char *)"-dCompressPages=false"; + } + /* + * The PostScript interpreters on many printers have bugs which make + * the interpreter crash, error out, or otherwise misbehave on too + * heavily compressed input files, especially if code with compressed + * elements is compressed again. Therefore we reduce compression here. + */ + pdf_argv[pdf_argc++] = (char *)"-dCompressFonts=false"; + pdf_argv[pdf_argc++] = (char *)"-dNoT3CCITT"; + if (ppd && ppd->manufacturer && + !strncasecmp(ppd->manufacturer, "Brother", 7)) + { + fprintf(stderr, "DEBUG: Deactivation of Ghostscript's image compression for Brother printers to workarounmd PS interpreter bug\n"); + pdf_argv[pdf_argc++] = (char *)"-dEncodeMonoImages=false"; + pdf_argv[pdf_argc++] = (char *)"-dEncodeColorImages=false"; + } + pdf_argv[pdf_argc++] = (char *)"-c"; + pdf_argv[pdf_argc++] = (char *)"save pop"; + pdf_argv[pdf_argc++] = (char *)"-f"; + pdf_argv[pdf_argc++] = filename; } - /* - * The PostScript interpreters on many printers have bugs which make - * the interpreter crash, error out, or otherwise misbehave on too - * heavily compressed input files, especially if code with compressed - * elements is compressed again. Therefore we reduce compression here. - */ - pdf_argv[pdf_argc++] = (char *)"-dCompressFonts=false"; - pdf_argv[pdf_argc++] = (char *)"-dNoT3CCITT"; - if (ppd && ppd->manufacturer && - !strncasecmp(ppd->manufacturer, "Brother", 7)) - { - fprintf(stderr, "DEBUG: Deactivation of Ghostscript's image compression for Brother printers to workarounmd PS interpreter bug\n"); - pdf_argv[pdf_argc++] = (char *)"-dEncodeMonoImages=false"; - pdf_argv[pdf_argc++] = (char *)"-dEncodeColorImages=false"; - } - pdf_argv[pdf_argc++] = (char *)"-c"; - pdf_argv[pdf_argc++] = (char *)"save pop"; - pdf_argv[pdf_argc++] = (char *)"-f"; - pdf_argv[pdf_argc++] = filename; -#endif /* HAVE_PDFTOPS */ pdf_argv[pdf_argc] = NULL; @@ -635,14 +689,13 @@ * of the printer's PostScript interpreter? */ -#ifdef HAVE_PDFTOPS - need_post_proc = 0; -#else - need_post_proc = - (ppd && ppd->manufacturer && - (!strncasecmp(ppd->manufacturer, "Kyocera", 7) || - !strncasecmp(ppd->manufacturer, "Brother", 7)) ? 1 : 0); -#endif /* HAVE_PDFTOPS */ + if (renderer == PDFTOPS) + need_post_proc = 0; + else + need_post_proc = + (ppd && ppd->manufacturer && + (!strncasecmp(ppd->manufacturer, "Kyocera", 7) || + !strncasecmp(ppd->manufacturer, "Brother", 7)) ? 1 : 0); /* * Execute "pdftops/gs | pstops [ | post-processing ]"... @@ -684,13 +737,16 @@ close(pstops_pipe[0]); close(pstops_pipe[1]); -#ifdef HAVE_PDFTOPS - execv(CUPS_PDFTOPS, pdf_argv); - perror("DEBUG: Unable to execute pdftops program"); -#else - execv(CUPS_GHOSTSCRIPT, pdf_argv); - perror("DEBUG: Unable to execute gs program"); -#endif /* HAVE_PDFTOPS */ + if (renderer == PDFTOPS) + { + execv(CUPS_POPPLER_PDFTOPS, pdf_argv); + perror("DEBUG: Unable to execute pdftops program"); + } + else + { + execv(CUPS_GHOSTSCRIPT, pdf_argv); + perror("DEBUG: Unable to execute gs program"); + } exit(1); } @@ -700,11 +756,10 @@ * Unable to fork! */ -#ifdef HAVE_PDFTOPS - perror("DEBUG: Unable to execute pdftops program"); -#else - perror("DEBUG: Unable to execute gs program"); -#endif /* HAVE_PDFTOPS */ + if (renderer == PDFTOPS) + perror("DEBUG: Unable to execute pdftops program"); + else + perror("DEBUG: Unable to execute gs program"); exit_status = 1; goto error; @@ -754,9 +809,7 @@ else printf("%s", buffer); -#ifndef HAVE_PDFTOPS - - if (ppd && ppd->manufacturer) + if (renderer == GS && ppd && ppd->manufacturer) { /* @@ -805,8 +858,6 @@ } } -#endif /* !HAVE_PDFTOPS */ - if (strncmp(buffer, "%%BeginProlog", 13)) { /* Close newly created Prolog section */ @@ -924,11 +975,7 @@ fprintf(stderr, "DEBUG: PID %d (%s) stopped with status %d!\n", wait_pid, -#ifdef HAVE_PDFTOPS - wait_pid == pdf_pid ? "pdftops" : -#else - wait_pid == pdf_pid ? "gs" : -#endif /* HAVE_PDFTOPS */ + wait_pid == pdf_pid ? (renderer == PDFTOPS ? "pdftops" : "gs") : (wait_pid == pstops_pid ? "pstops" : "Post-processing"), exit_status); } @@ -937,11 +984,7 @@ fprintf(stderr, "DEBUG: PID %d (%s) was terminated normally with signal %d!\n", wait_pid, -#ifdef HAVE_PDFTOPS - wait_pid == pdf_pid ? "pdftops" : -#else - wait_pid == pdf_pid ? "gs" : -#endif /* HAVE_PDFTOPS */ + wait_pid == pdf_pid ? (renderer == PDFTOPS ? "pdftops" : "gs") : (wait_pid == pstops_pid ? "pstops" : "Post-processing"), exit_status); } @@ -950,11 +993,7 @@ exit_status = WTERMSIG(wait_status); fprintf(stderr, "DEBUG: PID %d (%s) crashed on signal %d!\n", wait_pid, -#ifdef HAVE_PDFTOPS - wait_pid == pdf_pid ? "pdftops" : -#else - wait_pid == pdf_pid ? "gs" : -#endif /* HAVE_PDFTOPS */ + wait_pid == pdf_pid ? (renderer == PDFTOPS ? "pdftops" : "gs") : (wait_pid == pstops_pid ? "pstops" : "Post-processing"), exit_status); } @@ -962,11 +1001,7 @@ else { fprintf(stderr, "DEBUG: PID %d (%s) exited with no errors.\n", wait_pid, -#ifdef HAVE_PDFTOPS - wait_pid == pdf_pid ? "pdftops" : -#else - wait_pid == pdf_pid ? "gs" : -#endif /* HAVE_PDFTOPS */ + wait_pid == pdf_pid ? (renderer == PDFTOPS ? "pdftops" : "gs") : (wait_pid == pstops_pid ? "pstops" : "Post-processing")); } } diff -Nru cups-filters-1.0.17/INSTALL.txt cups-filters-1.0.18/INSTALL.txt --- cups-filters-1.0.17/INSTALL.txt 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/INSTALL.txt 2012-05-16 11:02:01.000000000 +0200 @@ -1,4 +1,4 @@ -INSTALL - OpenPrinting CUPS Filters v1.0.17 - 2012-04-20 +INSTALL - OpenPrinting CUPS Filters v1.0.18 - 2012-05-16 -------------------------------------------------------- This file describes how to compile and install OpenPrinting CUPS diff -Nru cups-filters-1.0.17/README.txt cups-filters-1.0.18/README.txt --- cups-filters-1.0.17/README.txt 2012-04-20 14:30:00.000000000 +0200 +++ cups-filters-1.0.18/README.txt 2012-05-16 11:02:01.000000000 +0200 @@ -1,4 +1,4 @@ -README - OpenPrinting CUPS Filters v1.0.17 - 2012-04-20 +README - OpenPrinting CUPS Filters v1.0.18 - 2012-05-16 ------------------------------------------------------- Looking for compile instructions? Read the file "INSTALL.txt" @@ -64,7 +64,7 @@ To get back to the old behavior, supply one of the options "nofitplot" "filplot=Off", "nofit-to-page", or "fit-to-page=Off". -POSTSCRIPT PRINTING DEBUG MODE +POSTSCRIPT PRINTING RENDERER AND RESOLUTION SELECTION If you use CUPS with this package and a PostScript printer then the included pdftops filter converts the print job data which is @@ -72,7 +72,64 @@ generated with Ghostscript's "ps2write" output device, which generates a DSC-conforming PostScript with compressed embedded fonts and compressed page content. This is resource-saving and - leads to fast wire transfer of print jobs to the rpinter. + leads to fast wire transfer of print jobs to the printer. + + Unfortunately, Ghostscript's PostScript output is not compatible + with some printers due to interpreter bugs in the printer and in + addition, processing (by Ghostscript or by the printer's + interpreter) can get very slow with high printing resolutions when + parts of the incoming PDF file are converted to bitmaps if they + contain graphical structures which are not supported by + PostScript. The bitmap problem especially occurs on input files + with transparency, especially also the ones produced by Cairo + (evince and many other GNOME/GTK applications) which unnecessarily + introduces transparency even if the input PDF has no transparency. + + Therefore there are two possibilities to configure pdftops at + runtime: + + 1. Selection of the renderer: Ghostscript or Poppler + + Ghostscript has better color management and is generally optimized + more for printing. Poppler produces a PostScript which is + compatible with more buggy built-in PostScript interpreters of + printers and it leads to a somewhat quicker workflow when + graphical structures of the input PDF has to be turned into + bitmaps. + + The selection is done by the "pdftops-renderer" option, setting it + to "gs" or "pdftops": + + Per-job: lpr -o pdftops-renderer=pdftops ... + Per-queue default: lpadmin -p printer -o pdftops-renderer-default=gs + Remove default: lpadmin -p printer -R pdftops-renderer-default + + By default, pdftops uses Ghostscript if this does not get changed + at compile time, for example by the Linux distribution vendor. + + 2. Limitation of the image rendering resolution + + If graphical structures of the incoming PDF file have to be + converted to bitmaps due to limitations of PostScript, the + conversion of the file by pdftops or the rendering by the printer + can get too slow if the bitmap resolution is too high or the + printout quality can degrade if the bitmap resolution is too low. + + By default, pdftops tries to find out the actual printing + resolution and sets the resolution for bitmap generation to the + same value. If it cannot find the printing resolution, it uses 300 + dpi. It never goes higher than a limit of 1440 dpi. Note that this + default limit can get changed at compile time, for example by the + Linux distribution vendor. + + The resolution limit for bitmaps can be changed to a lower or + higher value, or be set to unlimited. This is done by the option + "pdftops-max-image-resolution-default", setting it to the desired + value (in dpi) or to zero for unlimited. It can be used per-job or + as per-queue default as the "pdftops-renderer" option described + above. + +POSTSCRIPT PRINTING DEBUG MODE Sometimes a PostScript printer's interpreter errors, crashes, or somehow else misbehaves on Ghostscript's output. To find @@ -100,6 +157,9 @@ and print into this queue as described above. The PostScript output is in /tmp/printout after the job has completed. + This option does not change anything if Poppler's pdftops is used + as renderer. + CUPS FILTERS FOR PDF AS STANDARD PRINT JOB FORMAT Here is documentation from the former CUPS add-on tarball with the filters