Fix the pstoqpdl driver: allow printing from iOS devices by inserting a
dummy "%%Creator" line. from Martin Crossley
This commit is contained in:
parent
60f56bd30d
commit
37724428c3
@ -1,12 +1,12 @@
|
||||
# $OpenBSD: Makefile,v 1.12 2013/03/11 11:37:54 espie Exp $
|
||||
# $OpenBSD: Makefile,v 1.13 2013/04/07 08:47:33 ajacoutot Exp $
|
||||
|
||||
COMMENT= CUPS drivers for SPL printers
|
||||
|
||||
DISTNAME= splix-2.0.0
|
||||
REVISION = 7
|
||||
CATEGORIES= print
|
||||
|
||||
EXTRACT_SUFX= .tar.bz2
|
||||
REVISION = 8
|
||||
|
||||
CATEGORIES= print
|
||||
|
||||
HOMEPAGE= http://splix.ap2c.org/
|
||||
|
||||
@ -15,8 +15,7 @@ MAINTAINER= Antoine Jacoutot <ajacoutot@openbsd.org>
|
||||
# GPLv2
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
|
||||
WANTLIB += asn1 c crypto cups cupsimage gssapi jbig krb5 m pthread
|
||||
WANTLIB += ssl stdc++ z
|
||||
WANTLIB += c cups cupsimage jbig m pthread stdc++
|
||||
|
||||
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=splix/}
|
||||
|
||||
|
96
print/splix/patches/patch-src_pstoqpdl_cpp
Normal file
96
print/splix/patches/patch-src_pstoqpdl_cpp
Normal file
@ -0,0 +1,96 @@
|
||||
$OpenBSD: patch-src_pstoqpdl_cpp,v 1.1 2013/04/07 08:47:33 ajacoutot Exp $
|
||||
--- src/pstoqpdl.cpp.orig Fri Feb 6 12:49:10 2009
|
||||
+++ src/pstoqpdl.cpp Sun Apr 7 10:43:23 2013
|
||||
@@ -232,30 +232,86 @@ int main(int argc, char **argv)
|
||||
fprintf(stdout, "%s", (char *)&buffer);
|
||||
}
|
||||
} else {
|
||||
- // Check for the header
|
||||
+
|
||||
+ // Insert the MediaChoice and colour correction information into
|
||||
+ // the postscript header.
|
||||
+ //
|
||||
+ // Look for a "%%Creator" line in the postscript header, and
|
||||
+ // insert the information before it.
|
||||
+ //
|
||||
+ // Postscript that is created by pdftops from content from Apple
|
||||
+ // iOS devices (iPad etc) seems not to have a "%%Creator" line in
|
||||
+ // the header, so we insert a dummy one. Without this, pstoqpdl
|
||||
+ // seems to crash ghostscript.
|
||||
+ //
|
||||
+ // NB: according to the PostScript Document Structuring Conventions
|
||||
+ // (DSC) specification the end of the postscript header should be
|
||||
+ // the "%%EndComments" line - see:
|
||||
+ // http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf
|
||||
+
|
||||
+
|
||||
+ // search each line in the postscript header
|
||||
while (!(feof(stdin))) {
|
||||
+
|
||||
+ // read a line of the input file
|
||||
if (!fgets((char *)&buffer, sizeof(buffer), stdin))
|
||||
break;
|
||||
|
||||
- // End of the PS header ?
|
||||
if (!(memcmp("%%Creator", (char *)&buffer, 9))) {
|
||||
+ // found a "%%Creator" line
|
||||
+
|
||||
+ // emit the MediaChoice and colour correction information
|
||||
if (paperType)
|
||||
fprintf(stdout, "/MediaChoice (%s) def\n", paperType);
|
||||
fprintf(stdout, "%s", crd);
|
||||
fprintf(stdout, "%s", csa);
|
||||
+
|
||||
+ // emit the original "%%Creator" line
|
||||
fprintf(stdout, "%s", (char *)&buffer);
|
||||
+
|
||||
+ // stop scanning the header
|
||||
break;
|
||||
+ }
|
||||
|
||||
- // End of the header not found?
|
||||
- } else if (!(memcmp("%%%%BeginPro", (char *)&buffer, 10)) ||
|
||||
- !(memcmp("%%BeginRes", (char *)&buffer, 10)) ||
|
||||
- !(memcmp("%%EndComments", (char *)&buffer, 13))) {
|
||||
+
|
||||
+ if (!(memcmp("%%EndComments", (char *)&buffer, 13))) {
|
||||
+ // reached end of header without finding a "%%Creator" line
|
||||
+
|
||||
+ // emit the MediaChoice and colour correction information
|
||||
+ if (paperType)
|
||||
+ fprintf(stdout, "/MediaChoice (%s) def\n", paperType);
|
||||
+ fprintf(stdout, "%s", crd);
|
||||
+ fprintf(stdout, "%s", csa);
|
||||
+
|
||||
+ // emit a dummy "%%Creator" line
|
||||
+ DEBUGMSG(_("inserting dummy \"Creator\" entry in postscript header"));
|
||||
+ fprintf(stdout, "%s", "%%Creator: SpliX pstoqpdl filter");
|
||||
+
|
||||
+ // emit the original "%%EndComments" line
|
||||
+ fprintf(stdout, "%s", (char *)&buffer);
|
||||
+
|
||||
+ // stop scanning the header
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (!(memcmp("%%BeginPro", (char *)&buffer, 10)) ||
|
||||
+ !(memcmp("%%BeginRes", (char *)&buffer, 10))) {
|
||||
+ // we shouldn't find either of these lines in the header
|
||||
+
|
||||
ERRORMSG(_("End of PostScript header not found"));
|
||||
+
|
||||
+ // emit the line that was found
|
||||
fprintf(stdout, "%s", (char *)&buffer);
|
||||
+
|
||||
+ // stop scanning the header
|
||||
break;
|
||||
}
|
||||
+
|
||||
+ // encountered some other kind of header line - just emit it
|
||||
fprintf(stdout, "%s", (char *)&buffer);
|
||||
}
|
||||
+
|
||||
|
||||
// Check for each page
|
||||
while (!(feof(stdin))) {
|
Loading…
x
Reference in New Issue
Block a user