How do I add custom entries in the info dictionary?

Q: We usually set some custom document information fields for PDFs
that
appear in the Info dictionary in the root. Your API includes calls for
each of the standard fields, but no custom field or "generic" info
field
creation. So, I have used code to get the SDF object for the Info
dictionary and then put a string into that. e.g.

/* this code is cut down -- the SDFDoc etc are initialised */
TRN_SDFDoc dP;
TRN_PDFDocInfo info;

TRN_PDFDocInfoGetSDFObj(info, &dict);
if (dict) {
        TRN_Obj custom, str;

        TRN_SDFDocCreateIndirectString(dP, "test", 4, &str);
        TRN_ObjPut(dict, "MyCustomField", str, &custom);
} }

What happens with this (it changes depending on how I get the Info
dict)
is that the custom field seems to appear in the root (Catalog) object
and not the Info dictionary. Is there a way to get this to work?
Perhaps
it depends on when I try to create this field?
------
A: You can put custom fields in the info dictionary as shown in SDF
sample project:
  http://www.pdftron.com/pdfnet/samplecode.html#SDF

For example (in C#):

Obj info = doc.GetTrailer().FindObj("Info");
if (info != null) {
  info.PutString("My Key", "Hello");
  info.PutNumber("Key1", 123);
  Obj mydict = info.PutDict("Key2");
  Obj myarray = info.PutArray("MyArray");
  ...
}