Foxit PDF SDK for Windows

How to Add Attachments to your PDFs with Foxit PDF SDK (.NET)

With Foxit PDF SDK, attachments refer to documents rather than file attachment annotations. This allows whole files to be embedded in a document, much like email attachments. PDF SDK provides application APIs to access functions such as loading attachments, getting attachments, inserting/removing attachments, and accessing properties of attachments.

Example:

How to insert an attachment file into a PDF

using foxit;
using foxit.common;
using foxit.common.fxcrt;
using foxit.pdf;
using foxit.pdf.objects;
// Assuming PDFDoc doc has been loaded.
string text_path = "The input path of the attached file you need to insert";
Attachments attachments = new Attachments(doc, new PDFNameTree());
attachment.AddFromFilePath("OriginalAttachmentsInfo", text_path);
...

How to remove a specific attachment of a PDF

using foxit;
using foxit.common;
using foxit.common.fxcrt;
using foxit.pdf;
using foxit.pdf.objects;
// Assuming PDFDoc doc has been loaded.
...
Attachments attachment = new Attachments(doc, new PDFNameTree());
string strKey = attachment.GetKey(index);
attachment.RemoveEmbeddedFile(strKey);

Updated on April 23, 2019

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: