1
votes

Is it possible to embed a hidden file into a PDF using iText?

I have tried the following, but I don't want the file to show up in the File attachments tab.

stamper.addFileAttachment("Description", null, "file", "File name");

and

PdfFileSpecification pfs = PdfFileSpecification.fileEmbedded(stamper.getWriter(), "file", null, null,false);
stamper.addFileAttachment("Description",pfs);

I've heard I can embed the contents of the file with the metadata, is this possible?

1
You say that the file shall be embedded in a hidden way. This can be easily achieved by adding a stream object to the PdfWriter or PdfStamper. But the question is, how well hidden shall it be? Most likely you wont some program of yours to be able to find these data. How can that program access the PDF.mkl
I would be using a different java class to open the document and extract the data. I guess I don't want the file to be seen by ordinary user reading the document.v30

1 Answers

0
votes

I found another way to do what I wanted to, I'm saving the content of the file (it's a rather small one) into a hidden TextField object that I can later access with the getField method of AcroField.