Storing and manipulating custom metadata whithin PDF.

Q: I would like to be able to embed custom data (these will
constitute, say, C# collection of serialised rectangles -
List<MyRectangle>) into a PDF, save the file like that on disk and
also be able to read that data back. How would I go about it?
Also, I have to be able to remove that data and save the PDF in its
'original' (not necessarily original - just with my data removed)
state.

Do you have any suggestions what's the best way to embed this data
instead of using single stream of binary data?
-----
A: Probably the simplest approach is to use PDFNet’s SDF/Cos API to
store and manipulate custom data within a PDF document. For example,
you could store an array of rectangles within the given page object as
follows:

Obj my_arr = page.GetSDFObj().PutArray("_foobar_custom_array");
my_arr.PushBackRect(x1, y1, x2, y2);
...

To access this custom data you could use the following snippet:

Obj my_arr = page.GetSDFObj().FindObj("_foobar_custom_array");
if (my_arr != null) {
   int sz = my_arr.Size();
   for (int i=0; i<sz; ++i) {
      Obj rect_obj = my_arr.GetAt(i);
      Rect rect = new Rect(rect_obj);
      double w = rect.Width(), x1 = rect.x1;
      ...
   }
}

To erase this custom data from a PDF file use the following line:

page.GetSDFObj().Erase("_foobar_custom_array");

SDF sample project is a good place to get familiar with the API. You
may also want to refer to API Reference (http://www.pdftron.com/net/
html/classpdftron_1_1SDF_1_1Obj.html) as well as a short tutorial on
low-level PDF structure (http://pdftron.com/net/
usermanual.html#pdf_intro; please keep in mind that this tutorial
refers to some deprecated APIs - see www.pdftron.com/net/pdfnet4_upgrade.txt).