1

Recently, I'm coming across more and more places that use PDF files as a non-editable format to ensure that the data in it is not altered in any form. (Whether that is a good idea or not is another question altogether -- the general public "understand" PDF and know how to generate them easily from systems.)

However, what I'm having trouble with is coercing it into a text-friendly and parseable format that allows for analysis of the data in the PDF. pdftotext goes a long way, but there's almost always one small problem with its output that makes it a non-ideal solution.

Are there any solutions to this dilemma? What's a text-friendly file format that can be reasonably assured to be the original output from some software (without going through the hoops of signatures and encryption) that a layman would be able to open up and read easily?

Note: I'm well aware that all formats are editable, but it's not so readily apparent to the average user i.e. they would probably not know how to edit a PDF without some searching. Also, I'm not advocating for this, I'm just curious as to whether a text-friendlier format exists. I'm not going to be able to get a whole lot of people to understand what file signatures are, let alone generate them properly.

  • 1
    PDFs are just slightly more difficult to manipulate than other (text) formats. I don't think "text-friendly file format that can be reasonably assured to be the original output" is a good criterion. I'd suggest that you either use cryptography or accept that it may be manipulated. – Arminius Sep 16 '17 at 3:42
2

There is no file format which can prevent editing. It can only make it harder to do edits because writing an editor is too complex. This was the case with PDF but now there are enough editors for PDF already out there. Thus, to prevent easy editing you would need a complex and hard to understand format - exactly what you don't want. If you have a simple format then it will also be easy to write editors for it.

Instead of making sure that it is too hard to edit the data you should better find a way to detect such edits. And by separating the content from the protection you can create a format which is both easy to read and hard to manipulate undetected.

A common way to do this is to use digital signatures. Any signatures embedded in the file can simply be skipped by a human reader or when processed by a script. And such signatures can also be detached in separate files which makes it possible to add signatures to any file format.

Depending on the requirements for protection and usability when creating the document different qualities of signatures can be used. In the simplest case signature might just be a HMAC with the necessary secret key embedded into the application which creates the files. In this case this application itself must be secret or the key somehow protected against reverse engineering. Better protection is offered by author specific keys, use of smart cards etc but this might be too complex for your only vague defined use case.

| improve this answer | |
  • Yup I'm well aware of the fact. I'm trying to think of something that I can teach the average user to do without having to go through hoops. Hence reasonable assurance. Anything beyond that can be considered malicious intent since you'd have to search for tools to help you alter the file. Hence where PDFs come in--it requires specific tools to modify it and it is easily viewable. What it isn't is text-friendly since you can't very well chuck it into a script and expect good results quickly. – Alex Koay Sep 16 '17 at 10:28
  • @AlexKoay: see edited answer. In short: you cannot have a format simple for reading but too hard to edit unless you are able to protect the relevant parts. And, digital signatures don't need to be complex. If you just want to make it a bit harder use a fixed key embedded into the writing application and accept the risk that the key gets widely known. – Steffen Ullrich Sep 16 '17 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.