Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdftops in Ghostscript mode should use the "ps2write" output device of Ghostscript #3766

Closed
michaelrsweet opened this issue Jan 5, 2011 · 6 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Copy link
Collaborator

commented Jan 5, 2011

Version: 1.5-feature
CUPS.org User: till.kamppeter

In the upcoming Ghostscript 9.01 (to be released end of Feb 2011) the "ps2write" output device will produce DSC-conforming PostScript (gives PASS with current cupstestdsc) and therefore the old "pswrite" will get deprecated. Especially the old "pswrite" turns text characters into bitmaps and so output files will get huge which easily causes crashes of PostScript printers. The new "ps2write" handles text correctly and so files will not blow up. In addition, "pswrite" will most probably not get maintained any more.

Therefore I recommend that in the pdftops filter the "ps2write" output device of Ghostscript gets used when compiled in Ghostscript mode. Or better a check in ./configure should be done to check which Ghostscript version is installed and in case of 9.01 or newer "ps2write" should be used, otherwise "pswrite".

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 6, 2011

CUPS.org User: h.blischke

Why not augment the pdf2dsc.ps utility of Ghostscript in that it dumps the contents of the pdfpage dictionary to the specified output file? A wrapper script around Ghostscript could dump the necessary PS code fom the .../Resources/Init/xxx.ps files.

This would this solution make widely independent of the Ghostscript release in use (note that many Linux ditros still stick to 8.6x versions).

Postscriptum: I already have a procset that dumps PS objects; it only needs to be extended to dump fonts and images.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 7, 2011

CUPS.org User: mike

Moving to 1.5-feature...

Till, does ps2write exist in older versions of Ghostscript?

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 7, 2011

CUPS.org User: till.kamppeter

"ps2write" exists in older versions of Ghostscript, but the output was not DSC-conforming, so not suitable for further manipulation by pstops.

Therefore I recommend a check in ./configure and let "ps2write" only being used if GS is version 9.01 or newer.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented May 6, 2011

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented May 6, 2011

"use-gs-with-ps2write-device.patch":

#! /bin/sh /usr/share/dpatch/dpatch-run

use-gs-with-ps2write-device.dpatch by till.kamppeter@gmail.com

All lines beginning with `## DP:' are a description of the patch.

DP: No description.

@dpatch@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' cups-1.4.5~/filter/pdftops.c cups-1.4.5/filter/pdftops.c
--- cups-1.4.5~/filter/pdftops.c 2009-05-22 21:30:39.000000000 +0200
+++ cups-1.4.5/filter/pdftops.c 2010-12-21 14:48:01.834131145 +0100
@@ -270,7 +270,7 @@
pdf_argv[2] = (char *)"-dNOPAUSE";
pdf_argv[3] = (char *)"-dBATCH";
pdf_argv[4] = (char *)"-dSAFER";

  • pdf_argv[5] = (char *)"-sDEVICE=pswrite";
  • pdf_argv[5] = (char )"-sDEVICE=ps2write";
    pdf_argv[6] = (char *)"-sOUTPUTFILE=%stdout";
    pdf_argc = 7;
    #endif /
    HAVE_PDFTOPS */
@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented May 6, 2011

"str3766.patch":

Index: config-scripts/cups-pdf.m4

--- config-scripts/cups-pdf.m4 (revision 9747)
+++ config-scripts/cups-pdf.m4 (working copy)
@@ -1,9 +1,9 @@
dnl
dnl "$Id$"
dnl
-dnl PDF filter configuration stuff for the Common UNIX Printing System (CUPS).
+dnl PDF filter configuration stuff for CUPS.
dnl
-dnl Copyright 2007-2009 by Apple Inc.
+dnl Copyright 2007-2011 by Apple Inc.
dnl Copyright 2006 by Easy Software Products, all rights reserved.
dnl
dnl These coded instructions, statements, and computer programs are the
@@ -80,11 +80,25 @@
esac

if test "x$CUPS_PDFTOPS" != x; then

  • if $CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes 2>/dev/null; then
  • AC_MSG_CHECKING(whether pdftops supports -origpagesizes)
  • if ($CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes); then
  •   AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_PDFTOPS_WITH_ORIGPAGESIZES)
    
  • else
  •   AC_MSG_RESULT(no)
    
    fi
    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)
    
  •   AC_DEFINE(HAVE_GHOSTSCRIPT_PS2WRITE)
    
  • else
  •   AC_MSG_RESULT(no)
    
  • fi
    +fi

AC_DEFINE_UNQUOTED(CUPS_PDFTOPS, "$CUPS_PDFTOPS")
AC_DEFINE_UNQUOTED(CUPS_GHOSTSCRIPT, "$CUPS_GHOSTSCRIPT")
AC_SUBST(PDFTOPS)
Index: filter/pdftops.c

--- filter/pdftops.c (revision 9747)
+++ filter/pdftops.c (working copy)
@@ -276,7 +276,11 @@
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 */

Index: config.h.in

--- config.h.in (revision 9747)
+++ config.h.in (working copy)
@@ -510,6 +510,7 @@
*/

#undef HAVE_GHOSTSCRIPT
+#undef HAVE_GHOSTSCRIPT_PS2WRITE
#define CUPS_GHOSTSCRIPT "/usr/bin/gs"

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.