jorisschellekens / borb

borb is a library for reading, creating and manipulating PDF files in python.
https://borbpdf.com/
Other
3.4k stars 147 forks source link

How to set OCG layer’s Locked state to True/False? #159

Closed ranga-tolapi closed 1 year ago

ranga-tolapi commented 1 year ago

How to set OCG layer’s Locked state to True/False? So that, it shall reflect in the layer properties in adobe viewer. Please refer to the following screenshot.

E7888622-3871-4B19-BC74-DC4026F3F758

jorisschellekens commented 1 year ago

Hi @ranga-tolapi,

There is no utility function that will allow you to set this property easily.

However, borb represent a PDF document as a JSON-like object of nested arrays and dictionaries. So if you know where to look, you can simply change the PDF that way.

There is an example in the examples repository that handles OCG layers (the example uses these layers to insert the result of OCR into a PDF). You can look up that example and see how the code interacts with those layers.

Furthermore, the PDF specification is included in the repository. You can use it to get an idea of which property you would need to set.

Kind regards, Joris Schellekens