How to copy/clone a pdftron.PDF.Element ?

How can I make a clone of an Element object?

My goal is to use our proprietary renderer to render the elements of a page. In doing this I need to tell our renderer to apply clipping to output when it should apply.

I’m using an ElementReader to process elements of a page in the classic way. When I encounter a e_group_begin I want to push a copy of the element to a Stack(Of Element). Obviously if I push a reference to the ElementReader iterator the element represented on the stack will change as the loop iterates.

The pages I work with apply clipping to text. I find element structure such as:

  • Group Begin

  • Path - specifying clipping path

  • Text Begin

  • Text

  • Text

  • Text

  • Text- Text End- Group End

Since the group element and the clipping path elements are found on separate iterations, I need to preserve the context of the group. That is, when a group is found, push that element to the stack. When the clipping path is found I know it applies to the current group that is on the top of the stack, and issue a call to our renderer to begin clipping the text which follows. We don’t know the clipping window until we process the path that is within the group. We then iterate each text element, and when we get the group end, we pop the group off the stack, and I know the clipping path applied to it is done, so I must then call our renderer to end clipping text.

This would be very simple to solve if I could somehow clone an Element. Even a shallow copy. Perhaps it is not possible?

It would be great if you first explained why “My goal is to use our proprietary renderer to render the elements of a page” is important for you?

Why not use PDFNet’s rendering?