How to associate a PDF file attachment with a document (vs. page)?

Q:

Can we add any file as attachment to an existing pdf document?
I don’t wish to add any annotation on any page for that attachment,
just that it should appear as an attachment in the document->attachment
section.


A:

If you want to associates a file attachment with the entire document,
use pdfdoc.AddFileAttachment(“MyFile”, myfile_filespec).

If you want to create a file attachment annotation on a given page use,
you can call
Annot.CreateFileAttachment(). For example:

Annot file_attach = Annot.CreateFileAttachment(doc, new Rect(80, 280,
200, 320), “attach.txt”);
page.AnnotPushBack(file_attach);