1
0
mirror of https://github.com/Llewellynvdm/pdflayers.git synced 2024-11-21 19:35:09 +00:00

Merge pull request #17 from mara004/patch-1

Use capitalized Root
This commit is contained in:
Simon Segerblom Rex 2021-11-30 20:50:34 +01:00 committed by GitHub
commit 6ba297a298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
def set_layer_visibility(pdf, layers_to_show): def set_layer_visibility(pdf, layers_to_show):
"""Set visibility of layers.""" """Set visibility of layers."""
try: try:
ocgs = pdf.root.OCProperties.OCGs ocgs = pdf.Root.OCProperties.OCGs
except (AttributeError, KeyError): except (AttributeError, KeyError):
logger.error("Unable to locate layers in PDF.") logger.error("Unable to locate layers in PDF.")
sys.exit(1) sys.exit(1)
@ -29,7 +29,7 @@ def set_layer_visibility(pdf, layers_to_show):
Order=ocgs, Order=ocgs,
) )
pdf.root.OCProperties = pikepdf.Dictionary( pdf.Root.OCProperties = pikepdf.Dictionary(
D=ocgs_config, D=ocgs_config,
OCGs=ocgs, OCGs=ocgs,
) )