Skip to main content
Skip table of contents

Changing OCGs

Examples in response to questions such as:

 Also known as PDF layers, optional content groups (OCG) allow for graphics and text to be selectively made visible or invisible dynamically. Content that belongs to a certain group is visible when the group is on, and invisible when the group is off.

addocg

##GITHUB:https://github.com/itext/i7js-examples/blob/develop/src/main/java/com/itextpdf/samples/sandbox/stamper/AddOCG.java##

##GITHUB:https://github.com/itext/i7ns-samples/blob/develop/itext/itext.samples/itext/samples/sandbox/stamper/AddOCG.cs##

changeocg

##GITHUB:https://github.com/itext/i7js-examples/blob/develop/src/main/java/com/itextpdf/samples/sandbox/stamper/ChangeOCG.java##

##GITHUB:https://github.com/itext/i7ns-samples/blob/develop/itext/itext.samples/itext/samples/sandbox/stamper/ChangeOCG.cs##

changeocgorder

##GITHUB:https://github.com/itext/i7js-examples/blob/develop/src/main/java/com/itextpdf/samples/sandbox/stamper/ChangeOCGOrder.java##

##GITHUB:https://github.com/itext/i7ns-samples/blob/develop/itext/itext.samples/itext/samples/sandbox/stamper/ChangeOCGOrder.cs##

Resources

hello.pdf
ocg.pdf

Results

cmp_add_ocg.pdf

cmp_change_ocg.pdf

cmp_change_ocg_order.pdf


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.