Where Man Wins over ... PDF
non-editable or "secured" PDF
Until recently I encountered non-editable or "secured" PDF files only in some
account statements received by my bank, which occasionally the combination of
Acrobat Reader and CUPS was not able to print.
Recently (end 2018) however I heard some junior colleagues talking about non-editable PDF being
requested in support for some job applications. So I decided to go a little deep in
the matter.
- In fact one job announcement required the application form (if not sent in
hardcopy) to be sent by "certified electronic e-mail" (an idiosyncrasy of the
public administration in this country) as a "non-modifiable PDF".
Luckily the request was just for the application form, not for any other
attachment, and not for the publications (journal papers).
- A later job announcement instead requires the application form in "PDF/A format".
So I had a look about the way to produce such beasts.
- I started from a very simple PDF file, this one,
created via ps2pdf from a PostScript file
created by hand
If you issue the command pdfinfo or open it with Acrobat Reader and go
to Document -> Security -> Show Security Properties you will see there is no
protection of any sort (Show Details is dimmed out).
- Of course if you open the file with a text editor, you would be able to change it,
but it is unlikely you'd know what kind of edit to apply since the file is a
mixture of directives in plain ASCII and binary (compressed ?) data.
- Now to produce a non-editable version (just for fun I made it also non-printable)
I used the command
qpdf --encrypt '' ownpwd 40 --modify=n --print=n -- start.pdf secured.pdf
The result is here.
- Such file, when opened with Acrobat Reader, and going to
Document -> Security -> Show Security Properties -> Show Details, says
"Changing the document: not allowed". Similarly pdfinfo says
"Encrypted: yes (print:no copy:yes change:no addNotes:yes algorithm:RC4)"
Of course you can open the file with a text editor; you will note the usual
mixture of text and binary, and you will note that it is different from the
input. The difference is that it is encrypted so, even if you'd know how
to edit a normal PDF, here you have an additional layer of difficulty: to decrypt
the content you have to know the owner password (in this case lucio).
So a "not-editable" file actually is a "file editable by the owner only".
- If in the qpdf invocation I'd specified a non-blank user password before
the owner password, the resulting file would
require the user password (here lucio1) to be viewed and the owner
password (here lucio2) to be edited.
- Now to be really sure that what I think is a non-editable file cannot really be
edited, I need a PDF editor to open it.
It should not open it at all, unless I know the user password.
Such an editor is ... Libre Office !
If you open a (textual, not scanned) PDF with Libre Office, it will open it
in Draw. You can then modify it, but you shall not Save it
(it will save as an .odg drawing), but Export it as PDF.
- The Export menu of Libre Office (which is also available when one is composing
a text document within Libre Office itself) has a Security tab.
If a file is unprotected you have to Set Passwords first (at least an owner
password, which Libre Office calls permission password), and then you
will be allowed to set e.g. Changes to Not permitted.
The General tab allows to set the format to PDF/A but this is incompatible
with encryption and protection.
- Here is a file PDF/A saved from Libre Office after
an editing of the original start file. Of course it is unprotected.
- Here is a file protected and edited within Libre Office
(the owner password is the usual lucio).
- Here is a file created directly by Libre Office,
and protected by both an user (lucio1) and owner (lucio2) password.
- Summarising ...
- a normal PDF file can be opened with Acrobat Reader, gv or Libre Office
- a secured PDF file can be opened with Acrobat Reader, gv but requires the owner passowrd for Libre Office
- a protected PDF file can be opened with Acrobat Reader
specifying either password, is opened as blank by gv, and requires the owner password only with
Libre Office (the user password opens as uneditable)
- a PDF/A file by Libre Office can be opened as a normal file
- a secured PDF file by Libre Office can be opened as any secured file
- a protected PDF file by Libre Office can be opened as any protected file
As a crazy example on can produce (with qpdf) this file which has both password blank, so it
is encrypted, requests a password to be opened with Libre Office but reacts to a carriage return.
Now you may wonder if one can produce a PDF/A which is non-editable.
Well, this is not possible by definition. PDF/A is intended as a long-term archive
format (see wikipedia), intended not
to contain dynamic parts (e.g. forms) and to be readable everywhere and forever (for
this reason it has imbedded fonts). This is clearly in contradiction with encryption
as stated in the PDF/A FAQ.
Note also that a "secured" file (not modifiable unless one knows the owner password, but with
blank user password) can easily be unsecured (decrypted) with qpdf. Only a "protected" file (with two
passwords) cannot be decrypted unless one supplies the owner password. But of course, while an user
password is OK for a private exchange, one cannot distribute a public file with an user password.
It will be just a nuisance. So a "secured" file is not really protected, it is just a psychologic effect.
Finally qpdf --qdf produces a PDF file with almost no binary information, which, knowing
the PDF syntax, can be edited with a text editor. Here I edited by hand
the original file.
So why did the Unnominable Administration request a "non-modifiable PDF" in first
instance ? Possibly because it was afraid of possible falsifications.
But why did they replace the requirement with "PDF/A" later ? I suppose because
people had difficulties in producing non-editable files, and they thought a PDF/A
were protected ... which it isn't and cannot be.
I guess this is another case of the Asimov-Schiller effect.
sax.iasf-milano.inaf.it/~lucio/WWW/WhereManWins/pdf.html
:: original creation 2019 gen 29 16:10:00 CET ::
last edit 2019 Jan 29 16:10:00 CET