13

Is it possible to generate a PDF that is not editable?

Currently, the documents I generate using pdflatex may be edited with applications such as Adobe Acrobat X Pro.

I have some PDF documents which cannot be edited with Acrobat, so, how can I reproduce this with LaTeX?

Chico Sokol
  • 243
  • 1
  • 3
  • 6

2 Answers2

12

The PDF Toolkit is a free, command line application that provides this functionality. You set the "owner password" (owner_pw <password>) and specify which properties are allowed for the document. Here's an example (from the Pdftk Examples page) that encrypts the document with 128-Bit Strength and allows printing only:

pdftk mydoc.pdf output mydoc.128.pdf owner_pw foopass allow printing

It yields the following Document Properties in Adobe:

enter image description here

Other permissions can be set as well (from the Pdftk Man page):

[ allow < permissions > ]

Permissions are applied to the output PDF only if an encryption strength is specified or an owner or user password is given. If permissions are not specified, they default to ’none,’ which means all of the following features are disabled.

The permissions section can include one or more of the following features:

  • Printing – Top Quality Printing
  • DegradedPrinting – Lower Quality Printing
  • ModifyContents – Also allows Assembly
  • Assembly
  • CopyContents – Also allows ScreenReaders
  • ScreenReaders
  • ModifyAnnotations – Also allows FillIn
  • FillIn
  • AllFeatures – Allows the user to perform all of the above, and top quality printing.

As it turns out, these security features is very much viewer dependent and there are ways around it.

Werner
  • 364
  • 2
  • 12
  • Is it robust? Most of the time these restrictions are easy to circumvent by converting to post script and back to pdf. – M. Toya Oct 04 '12 at 18:06
  • @AlfredM.: I have not checked. Have you? – Werner Oct 04 '12 at 18:28
  • no, I was just curious. – M. Toya Oct 04 '12 at 18:43
  • 3
    @ Alfred M.: Any solution of this kind is not robust per definition. Indeed, if one can see the content of a PDF file, he can also save it in another PDF/PS/... file. It is just a question of finding the right tools (Acrobat will refuse to do so not because it cannot but because Adobe does not _want_ it to do so). –  Oct 04 '12 at 19:07
  • The DRM applied here is weak, but still strong enough to keep honest people honest. As long as your expectations are tuned accordingly, it is robust enough. Think of it as a contract between the document producer and PDF consuming software. Compliant software will respect the contract and thus act according to the restrictions listed. Adobe, as the originator of PDF, naturally faithfully follows the contract. However, under the hood, all DRM is fatally flawed and depends on arbitrary law such as the DMCA to prevent users from subverting it. – RBerteig Oct 04 '12 at 23:55
  • @amorua: It's possible to add a password to the file that is asked to open/see the file. – Werner Oct 04 '12 at 23:59
  • Some pdf readers like evince don't respect these passwords. –  Oct 05 '12 at 00:17
  • It did not work. I'm still able to edit the pdf with Adobe Acrobat Pro X... But thanks for the help! –  Oct 05 '12 at 17:11
10

I will add this as an answer, because it answers the question somehow and it is long and a bit complicated. The short answer is: no, it is not possible. Once you can read the PDF on your screen, it means that there's all the information and the PDF can be edited. Adobe programs of course do not offer such functionality. But if you want the PDF to be editable, you can always use ImageMagick:

convert -density 600 myfile.pdf myfile.png

Afterwards, since the quality is very high, any sufficiently good OCR will be able to convert it back to text. And there are surely other possibilites. As was mentioned by the other people, you can decode the PDF to PS (which is possible because to some extent, this is what the PDF reader has to do) and then convert back, and you have an editable PDF file.

Conclusion: You can protect the PDF from edits by "normal" users, but you cannot protect it from edits by people who know what they are doing.

yo'
  • 499
  • 5
  • 15
  • Even "normal" users can print (if allowed) to PDF. –  Oct 04 '12 at 19:28
  • There are methods that makes the PDF print a completely black page for the normal user. I know that some scientific journals do it to allow people to see the article, but not to print it. Still, even this can be cracked, it's the same as making it "non-editable". – yo' Oct 04 '12 at 19:33
  • @tohecz : I'm sure you're right; but I find the idea of a "non-printable pdf" both amusing and tragic. Bit like having a program you can't execute. If it's not for printing, pdf is an awful format for anything else. – Brent.Longborough Oct 05 '12 at 08:21
  • @Brent.Longborough I cannot agree I think. It is portable (i.e. working on all platforms including xindles) and it's well scalable. And it's what people like the most when they want a "document". – yo' Oct 05 '12 at 10:44
  • @tohecz : OK, we must agree to differ, then. My view is that PDF is good for "slide presentations" and printing. For "normal online viewing" it's really user-hostile, if only because it doesn't reflow, so you're at the mercy of the original designer and his particular screen resolution. – Brent.Longborough Oct 05 '12 at 14:55
  • Yes, I know it's impossible to completely protect the pdf. I just want to make it harder for people simply freely edit them in a common software such as Adobe Acrobat. Creating a image, as you suggested, is not a option for me. Thank you very much anyway! –  Oct 05 '12 at 17:14
  • @FranciscoSokol I included this here just to _make everybody sure_ that no method is bullet-proof ;) – yo' Oct 05 '12 at 17:31
  • @Brent.Longborough While I do agree that sometimes the non re-flowing part can be annoying, the `P`, though, stands for portable, not printing. –  Oct 05 '12 at 17:35
  • 1
    @Qrrbrbirlbel : It was so named by its creator, Adobe. Not my idea of a reference model for absolute truth. "Portable" is a corporate-speak buzzword, for selling ideas to pointy-haired managers. – Brent.Longborough Oct 05 '12 at 17:59