How do I remove a layer added by the PDFLayersTest code?

Question:

We add layers to pdf pages using code derived from the PDFLayersTest project.

However, sometimes we need to remove/erase one or more of these layers later on, how can we do that?

Answer:

The attached code will erase the layer named in the layerToRemove variable.

ElementEditTest.cs (3.7 KB)