I want to store a large string in PDF document somewhere hidden. Right now I have a hidden text field in which I am writing that text. The problem is that when the string size increased upto 10MB I start getting OutOfMemory
errors.
What will be the best way to store some large hidden string/text to PDF document using iTextSharp
? That text/string should be retrieved later as well.
Such private data can be stored in PieceInfo dictionaries, also cf. David's answer to the OP's follow-up question.
This answer to the older question "Insert hidden digest in pdf using iText library" shows how to make use of PieceInfo dictionaries in general using iText/Java (differences to iTextSharp/C# should be minimal here).
As the OP talks about data 10 MB and up, he may want to use PDF streams instead of strings.
The
DocumentPieceInfo
helper class provided in that older answer can be used with PDF streams for BIG DATA like this (again in Java as I'm mostly living on the Java side, and again porting to C# should be easy):Storing document PieceInfo data
Retrieving document PieceInfo data