The demo uses this code to show an editor and writes back the XML
Code
var s : string;
begin
if pdf<>nil then
begin
s := pdf.CommandGetStr(COMPDF_Ann_XMLGetFromAnnots, '###', 0);
if ShowPopupEditor('Modify Annotations', s, true) then
begin
s := StringReplace(s, #13+#10, #32, [rfReplaceAll]);
s := StringReplace(s, #10, #32, [rfReplaceAll]);
pdf.CommandStrEx(COMPDF_Ann_XMLSetToAnnots, s, 0);
end;
end;
end;