Q: Thanks for your response. Can you point me to an example for use
of
annot.GetAppearance(), ElementReader, and ElementWriter for this
purpose? Or can you tell me where this is covered in the
documentation?
A: As a starting point you may want to take a look at ElementReader,
ElementReaderAdv, and Annotation sample projects:
You can merge annotations by copying the content from the annotation
appearance stream to the target page. Something along the following
lines:
// Assuming you are using C# …
int num_annots = page.GetNumAnnots();
for (int i=0; i<num_annots; ++i) {
Annot annot = page.GetAnnot(i);
if (annot.GetType() == Annot.Type.e_Stamp) {
Obj app_stm = annot.GetAppearance();
if (app_stm != null) {
ElementReader reader = new ElementReader();
reader.Begin(app_stm);
ElementWriter writer = new ElementWriter();
writer.Begin(page);
Element element;
while ((element = reader.Next()) != null) {
//… You may also need to recursively process form
XObjects
// ProcessElement() in ElementReader and ImageExtract samples
for examples
writer.WriteElement(element);
}
writer.End();
reader.End()
writer.Dispose();
reader.Dispose();
}
}
}
After merging all annotations with the page, you can remove the
annotation using page.AnnotRemove(annot).
for (i=0; i<num_annots; ++i) {
Annot annot = page.GetAnnot(i);
page.AnnotRemove(annot);
}