PDFのレイヤー(OGG)は下記のコードで取得できました。
使ったPDFはここのexsample
非表示のレイヤーは'/OFF': [IndirectObject(11, 0), IndirectObject(12, 0)]のところみたいですね。レイヤー名はRadio Button Groupが'/RBGroups'とかになったりしてるので、少し分かりづらいようです。
python3
1from PyPDF2 import PdfFileReader
2with open('test2.pdf', mode="rb") as f:
3 pdf = PdfFileReader(f)
4 OGG = pdf.trailer['/Root']['/OCProperties']
5print(OGG)
6
7"""
8{'/OCGs': [IndirectObject(1, 0), IndirectObject(2, 0), IndirectObject(3, 0), IndirectObject(4, 0), IndirectObject(5, 0), IndirectObject(6, 0), IndirectObject(7, 0), IndirectObject(8, 0), IndirectObject(9, 0), IndirectObject(10, 0), IndirectObject(11, 0), IndirectObject(12, 0), IndirectObject(13, 0)], '/D': {'/RBGroups': [[IndirectObject(11, 0), IndirectObject(12, 0), IndirectObject(13, 0)]], '/Locked': [IndirectObject(8, 0), IndirectObject(9, 0)], '/Order': [IndirectObject(1, 0), [IndirectObject(2, 0), IndirectObject(3, 0), IndirectObject(4, 0)], ['PDF Drawing Layer', IndirectObject(5, 0), IndirectObject(6, 0), IndirectObject(7, 0), IndirectObject(8, 0), IndirectObject(9, 0)], IndirectObject(10, 0), [IndirectObject(11, 0), IndirectObject(12, 0), IndirectObject(13, 0)]], '/Name': 'PDF Filler Layer', '/OFF': [IndirectObject(11, 0), IndirectObject(12, 0)], '/ListMode': '/VisiblePages'}}
9"""
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/17 11:26