summaryrefslogtreecommitdiff
path: root/test/pdfclean.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-10-06 08:06:19 +0200
committerTor Andersson <tor@ghostscript.com>2004-10-06 08:06:19 +0200
commit57575cabd50c4fdadb7de8ed5dec5702be7c3954 (patch)
treeda09457a3ee6541db8024b55207b2426b808ce93 /test/pdfclean.c
parent5f8db4fe8444226788725fddc0face278f0540bc (diff)
downloadmupdf-57575cabd50c4fdadb7de8ed5dec5702be7c3954.tar.xz
encrypt when writing
Diffstat (limited to 'test/pdfclean.c')
-rw-r--r--test/pdfclean.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/pdfclean.c b/test/pdfclean.c
index 3a111a92..c6af657b 100644
--- a/test/pdfclean.c
+++ b/test/pdfclean.c
@@ -67,6 +67,7 @@ int main(int argc, char **argv)
pdf_xref *xref;
int c;
+ pdf_crypt *encrypt = 0;
int doencrypt = 0;
int dorepair = 0;
int doexpand = 0;
@@ -122,13 +123,26 @@ int main(int argc, char **argv)
if (error) fz_abort(error);
}
+ if (doencrypt)
+ {
+ fz_obj *id = fz_dictgets(xref->trailer, "ID");
+ if (!id)
+ fz_packobj(&id, "[(ABCDEFGHIJKLMNOP)(ABCDEFGHIJKLMNOP)]");
+ else
+ fz_keepobj(id);
+ error = pdf_newencrypt(&encrypt, userpw, ownerpw, perms, keylen, id);
+ if (error)
+ fz_abort(error);
+ fz_dropobj(id);
+ }
+
if (doexpand)
expandstreams(xref);
if (dogc)
pdf_garbagecollect(xref);
- error = pdf_savepdf(xref, outfile);
+ error = pdf_savepdf(xref, outfile, encrypt);
if (error)
fz_abort(error);