Ok, it seems that people don't want xpdf to disallow copying etc, but do wish to compromise with the author's wishes. So, a new patch: By default xpdf (and pdftotext, and pdftops) act normally - not allowing things if the bit are set. If you try to do something not allowed, a message is printed to stderr: "Error: Copying of text from this document is not allowed. Use -ignoreperms option to do so anyway" If you give the -ignoreperms option to any of the xpdf programs it runs uncrippled. Everyone happy? AGL -- Never underestimate the power of a small tactical nuclear weapon.
--- XRef.cc Mon Dec 4 04:28:07 2000
+++ ../../xpdf-aclean/xpdf/XRef.cc Sun Mar 11 17:28:01 2001
@@ -36,6 +36,7 @@
// Permission bits
//------------------------------------------------------------------------
+bool ignore_perms;
#define permPrint (1<<2)
#define permChange (1<<3)
#define permCopy (1<<4)
@@ -492,6 +493,8 @@
GBool XRef::okToPrint() {
#ifndef NO_DECRYPTION
if (!(permFlags & permPrint)) {
+ if (ignore_perms)
+ return gTrue;
return gFalse;
}
#endif
@@ -501,6 +504,8 @@
GBool XRef::okToChange() {
#ifndef NO_DECRYPTION
if (!(permFlags & permChange)) {
+ if (ignore_perms)
+ return gTrue;
return gFalse;
}
#endif
@@ -510,6 +515,8 @@
GBool XRef::okToCopy() {
#ifndef NO_DECRYPTION
if (!(permFlags & permCopy)) {
+ if (ignore_perms)
+ return gTrue;
return gFalse;
}
#endif
@@ -519,6 +526,8 @@
GBool XRef::okToAddNotes() {
#ifndef NO_DECRYPTION
if (!(permFlags & permNotes)) {
+ if (ignore_perms)
+ return gTrue;
return gFalse;
}
#endif
--- XRef.h Mon Dec 4 04:28:07 2000
+++ XRef.h Sun Mar 11 17:42:49 2001
@@ -23,6 +23,8 @@
// XRef
//------------------------------------------------------------------------
+extern bool ignore_perms;
+
struct XRefEntry {
int offset;
int gen;
--- pdftops.cc Mon Dec 4 04:28:07 2000
+++ pdftops.cc Sun Mar 11 18:00:27 2001
@@ -67,6 +67,8 @@
"print usage information"},
{"-help", argFlag, &printHelp, 0,
"print usage information"},
+ {"-ignoreperms", argFlag,&ignore_perms, 0,
+ "ignore permissions on the document"},
{NULL}
};
@@ -122,7 +124,7 @@
// check for print permission
if (!doc->okToPrint()) {
- error(-1, "Printing this document is not allowed.");
+ error(-1, "Printing this document is not allowed. Use -ignoreperms option to do so anyway");
goto err1;
}
--- pdftotext.cc Mon Dec 4 04:28:07 2000
+++ pdftotext.cc Sun Mar 11 17:54:40 2001
@@ -66,6 +66,8 @@
"print usage information"},
{"-help", argFlag, &printHelp, 0,
"print usage information"},
+ {"-ignoreperms", argFlag, &ignore_perms, 0,
+ "ignore permissions on the document"},
{NULL}
};
@@ -114,7 +116,7 @@
// check for copy permission
if (!doc->okToCopy()) {
- error(-1, "Copying of text from this document is not allowed.");
+ error(-1, "Copying of text from this document is not allowed. Use -ignoreperms option to do so anyway");
goto err;
}
--- xpdf.cc Mon Dec 4 04:28:07 2000
+++ xpdf.cc Sun Mar 11 18:16:42 2001
@@ -219,6 +219,7 @@
{"-paperw", ".psPaperWidth", XrmoptionSepArg, NULL},
{"-paperh", ".psPaperHeight", XrmoptionSepArg, NULL},
{"-level1", ".psLevel1", XrmoptionNoArg, (XPointer)"false"},
+ {"-ignoreperms", ".ignoreperms", XrmoptionNoArg, (XPointer) "on"},
{NULL}
};
@@ -286,6 +287,8 @@
"print usage information"},
{"-help", argFlag, &printHelp, 0,
"print usage information"},
+ {"-ignoreperms",argFlagDummy, NULL, 0,
+ "ignore permissions on this document"},
{NULL}
};
@@ -542,6 +545,10 @@
paperColor = app->getColorResource("paperColor", "white",
WhitePixel(display, app->getScreenNum()),
NULL);
+
+ // handle permissions
+ ignore_perms = app->getBoolResource ("ignoreperms", gFalse);
+
#if JAPANESE_SUPPORT
useEUCJP = app->getBoolResource("eucjp", gFalse);
#else
@@ -1229,7 +1236,7 @@
s = out->getText(selectXMin, selectYMin, selectXMax, selectYMax);
win->setSelection(NULL, s);
} else {
- error(-1, "Copying of text from this document is not allowed.");
+ error(-1, "Copying of text from this document is not allowed. Use -ignoreperms option to do so anyway");
}
#endif
@@ -2129,7 +2136,7 @@
}
delete psOut;
} else {
- error(-1, "Printing this document is not allowed.");
+ error(-1, "Printing this document is not allowed. Use -ignoreperms option to do so anyway");
}
delete psDialog;
Attachment:
pgpyzVdg6q7bd.pgp
Description: PGP signature