How do I insert arbitrary binary data within a PDF file?

Q:

We need to insert a binary "object" within the PDF. Is it possible
(using PDFNet) to insert arbitrary binary data (such as a zip file)
within a PDF file? This data should not be visible to any other reader
etc.
----

A:

Using PDFNet SDK you could insert arbitrary binary data within a PDF
file.

One approach is illustrated in SDFTest sample project (http://
www.pdftron.com/net/samplecode.html#SDF):

// Embed a custom stream (file my_stream.dat) in C#.
StdFile embed_file = new StdFile("my_stream.dat",
StdFile.OpenMode.e_read_mode);
FilterReader mystm = new FilterReader(embed_file);
mydict.Put("__My_Custom_Key", doc.CreateIndirectStream(mystm));

// Embed a custom stream (file my_stream.dat) in C++.
StdFile embed_file((input_path + "my_stream.txt").c_str(),
StdFile::e_read_mode );
FilterReader mystm(embed_file);
Mydict->Put("__My_Custom_Key", FileStream::CreateIndirect(doc,
mystm));

Using this approach you can attach a binary stream to any object in
PDF file via custom keys and SDF structures.

Another approach is to use more standardized approach to attach binary
files to PDF - i.e. as PDF attachments:
pdfdoc.AddFileAttachment("MyFile", myfile_filespec).