I'm looking for a way to add password security to a PDF. It is going to be used for proof PDF files for customers. They are not allowed to print the PDF or change it in any way.
Does anybody have a workflow/script for that? Thanks in advance!
Add password security to PDF
-
- Member
- Posts: 85
- Joined: Thu Jun 23, 2011 11:41 am
Add password security to PDF
You can use CPDF to do it, likewise, you can add a "proof" watermark... http://www.coherentpdf.com/
Encryption is page 13 of the user guide:
4.1 Introduction
PDF files can be encrypted using various types of encryption and attaching various permissions
describing what someone can do with a particular document (for instance, printing it
or extracting content). There are two types of person:
The User can do to the document what is allowed in the permissions.
The Owner can do anything, including altering the permissions.
There are three kinds of encryption: 40-bit encryption (method 40bit) in Acrobat 3 (PDF
1.1) and above, 128-bit encryption (method 128bit) in Acrobat 5 (PDF 1.4) and above, and
AES encryption (method AES) in Acrobat 7 (PDF 1.6) and above.
All encryption supports these kinds of permissions:
-no-edit Cannot change the document
-no-print Cannot print the document
-no-copy Cannot select or copy text or graphics
-no-annot Cannot add or change form fields or annotations
In addition, 128-bit encryption (Acrobat 5 and above) and AES encryption supports these:
-no-forms Cannot edit form fields
-no-extract Cannot extract text or graphics
-no-assemble Cannot merge files etc.
-no-hq-print Cannot print high-quality
Add these flags to the command line to prevent each operation.
Encryption is page 13 of the user guide:
4.1 Introduction
PDF files can be encrypted using various types of encryption and attaching various permissions
describing what someone can do with a particular document (for instance, printing it
or extracting content). There are two types of person:
The User can do to the document what is allowed in the permissions.
The Owner can do anything, including altering the permissions.
There are three kinds of encryption: 40-bit encryption (method 40bit) in Acrobat 3 (PDF
1.1) and above, 128-bit encryption (method 128bit) in Acrobat 5 (PDF 1.4) and above, and
AES encryption (method AES) in Acrobat 7 (PDF 1.6) and above.
All encryption supports these kinds of permissions:
-no-edit Cannot change the document
-no-print Cannot print the document
-no-copy Cannot select or copy text or graphics
-no-annot Cannot add or change form fields or annotations
In addition, 128-bit encryption (Acrobat 5 and above) and AES encryption supports these:
-no-forms Cannot edit form fields
-no-extract Cannot extract text or graphics
-no-assemble Cannot merge files etc.
-no-hq-print Cannot print high-quality
Add these flags to the command line to prevent each operation.
Add password security to PDF
Thanks Clive for your quick response, I will look into it! It sounds like a perfect solution to the problem.
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Add password security to PDF
Here's a free solution I developed using qpdf (http://qpdf.sourceforge.net)
// Encrypt/Decrypt PDF files using qpdf
//
// Written by Dwight Kelly <dkelly@apago.com>
// Copyright 2012 by Apago, Inc. -- All Rights Reserved
function jobArrived( s : Switch, job : Job )
{
var appPath = "/opt/local/bin/qpdf";
var String args = new Array();
var argc = 0;
args[argc++] = appPath;
if (s.getPropertyValue("encrypt") == "Yes") {
args[argc++] = "--encrypt";
args[argc++] = ""; // no user (open) password
args[argc++] = s.getPropertyValue("password"); // owner password
args[argc++] = "128";
args[argc++] = "--use-aes=y"; // 128-bit AES
args[argc++] = "--print=full"; // permissions
args[argc++] = "--modify=annotate";
args[argc++] = "--extract=n";
args[argc++] = "--";
} else {
args[argc++] = "--decrypt";
args[argc++] = "--password=" + s.getPropertyValue("password");
}
args[argc++] = job.getPath();
var String outFile = job.createPathWithName(job.getName()); // output file
args[argc++] = outFile;
var exitStatus = Process.execute(args);
var pdfFile = new File(outFile);
if (exitStatus == 0 && pdfFile.exists) {
// success
job.sendToSingle( outFile, job.getName() );
return;
}
// failure
job.fail("qpdf failed, errcode:" + exitStatus );
}
Learn advanced Javascript for Switch
Full day seminar during Graph Expo in Chicago, Oct 8th, 2012
http://www.brownpapertickets.com/event/264833
Dwight Kelly
Apago, Inc.
dkelly@apago.com
// Encrypt/Decrypt PDF files using qpdf
//
// Written by Dwight Kelly <dkelly@apago.com>
// Copyright 2012 by Apago, Inc. -- All Rights Reserved
function jobArrived( s : Switch, job : Job )
{
var appPath = "/opt/local/bin/qpdf";
var String args = new Array();
var argc = 0;
args[argc++] = appPath;
if (s.getPropertyValue("encrypt") == "Yes") {
args[argc++] = "--encrypt";
args[argc++] = ""; // no user (open) password
args[argc++] = s.getPropertyValue("password"); // owner password
args[argc++] = "128";
args[argc++] = "--use-aes=y"; // 128-bit AES
args[argc++] = "--print=full"; // permissions
args[argc++] = "--modify=annotate";
args[argc++] = "--extract=n";
args[argc++] = "--";
} else {
args[argc++] = "--decrypt";
args[argc++] = "--password=" + s.getPropertyValue("password");
}
args[argc++] = job.getPath();
var String outFile = job.createPathWithName(job.getName()); // output file
args[argc++] = outFile;
var exitStatus = Process.execute(args);
var pdfFile = new File(outFile);
if (exitStatus == 0 && pdfFile.exists) {
// success
job.sendToSingle( outFile, job.getName() );
return;
}
// failure
job.fail("qpdf failed, errcode:" + exitStatus );
}
Learn advanced Javascript for Switch
Full day seminar during Graph Expo in Chicago, Oct 8th, 2012
http://www.brownpapertickets.com/event/264833
Dwight Kelly
Apago, Inc.
dkelly@apago.com
Add password security to PDF
Thank you Dwight for your solution, i will try it!