I have a PDF file that I want to embed an invisible and fragile digital watermark. What are the suitable algorithms available for this task?
The majority of PDF readers will stop reading the PDF data stream upon hitting the
So, it would be perfectly feasible to calculate HMAC-SHA1 and append the resulting hash to the PDF file.
This is not, strictly speaking, a watermark -- but it is invisible and fragile, as requested.
Your resulting PDF file would end in something like
from which integrity can be straightforwardly calculated.
With the help of the
The stream length will be changed; if there is enough slack in the XMP object, you might circumvent this, but there's no need, since
In this latter case, the HMAC information will be compressed and not be directly readable. You will need
The procedure would be as follows:
You can do the same with a PDF object embedded in the PDF stream, e.g. using the iText library, but this would be much more complicated to be made fragile. PDF objects are largely independent from one another, so you would need to again recourse to something similar to HMAC, this time at object level, and then embed the value as e.g. 100% transparent text, or text outside the page boundaries (I know eBook publishers that employ one or both techniques).
Also with iText, but these are not fragile, are algorithms that modulate spacing of text objects on the page. Most text objects are not aligned to an integer multiple of the page unit:
and you can easily determine the minimum step that will be visible to the naked eye, e.g. 0.005. Then simply round all text positions, in the order they appear, to the nearest odd multiple of the step, if you want to encode an 1. Or to the nearest even multiple of the step, if you want to encode a 0.
Such a watermark will survive copy and be present independently on each page; with the addition of suitable error recovery (turbo code, Reed-Solomon...), it will also survive the removal or addition of some (not too many, of course...) objects on the page. It is also possible that it will survive printing and be recoverable from a scan of a printed page.
You would do this by implementing a iText