How can I make changes to content stream with nested form XObjects without cloning?

Q:

I ’m using the C# version of PDFNet. Part of our process involves creating a rasterized version of a given page with all text hidden. The general approach that I have employed basically mirrors ElementEditTest.cs.

For example:

…. Main page iterator

for (int i = 1; i <= num_pages; ++i) {
Page page = doc.GetPage(i);
reader.Begin(page);
writer.Begin(page, ElementWriter.WriteMode.e_replacement, false);
ProcessElements(reader, writer);
writer.End();
reader.End();
}

static void ProcessElements(ElementReader reader, ElementWriter writer)
{
Element element;
while ((element = reader.Next()) != null) // Read page contents
{
switch (element.GetType())
{
case Element.Type.e_text: // Process text strings…
{
// make the text hidden
break;
}
case Element.Type.e_form: // Recursively process form XObjects
{
reader.FormBegin();
ProcessElements(reader, writer);
reader.End();
break;
}
}

writer.WriteElement(element);
}
}

The problem that I am having involves a single document which contains an image at the footer which is embedded within nested levels of forms. I’m attaching a sample page. The footer image has some form of transparency or mask (see attachment). However, when run through the above the transparency is lost. I suspect this is due to form handling such that the above logic flattens out the form content in reverse order. What is the proper way to handle this case? Or, do you have a better suggestion to hide all of the text in a document other than what I’m trying to do?

A:

The following article covers this topic:
https://groups.google.com/d/topic/pdfnet-sdk/t0xlC27i10Q/discussion