我想用 python 和 popplerqt4 更改 PDF 文件中现有高亮注释的颜色。我有一个包含现有 HighlightAnnotations 的 PDF 文档。对于给定的页面,我可以使用以下方法检索注释:
In [1]: doc = popplerqt4.Poppler.Document.load('doc.pdf')
In [2]: annotations = doc.page(0).annotations()
在这种情况下,它返回两个 Highlight 类型的注释。
In [3]: annotations
Out[3]:
[<popplerqt4.HighlightAnnotation at 0x7f4cbc170948>,
<popplerqt4.HighlightAnnotation at 0x7f4cbc170558>]
setAuthor()
现在我可以分别使用和setHighlightQuads()
方法更改作者或更改这些注释的四边形。这非常有效,并且在保存文档时具有预期的行为(使用pdfConverter()
)。
我的问题是,annotations
上面给出的改变高光颜色的正确方法是什么?例如,我已经在他们使用的几个 c++ 示例中看到过annot->style().setColor( RED );
。如何使用 python 访问我的注释的样式属性?在我的示例中,我只能访问以下属性。提前感谢您的任何提示!
In [4]: annot = annotations[0]
In [4]: annot.
annot.ACaret annot.Dashed annot.NoEffect annot.creationDate
annot.AFileAttachment annot.Delete annot.None annot.flags
annot.AGeom annot.DenyDelete annot.Quad annot.highlightQuads
annot.AHighlight annot.DenyPrint annot.Rejected annot.highlightType
annot.AInk annot.DenyWrite annot.Reply annot.modificationDate
annot.ALine annot.External annot.RevScope annot.setAuthor
annot.ALink annot.FixedRotation annot.RevType annot.setBoundary
annot.AMovie annot.FixedSize annot.Solid annot.setContents
annot.ASound annot.Flag annot.Squiggly annot.setCreationDate
annot.AStamp annot.Group annot.StrikeOut annot.setFlags
annot.AText annot.Hidden annot.SubType annot.setHighlightQuads
annot.A_BASE annot.Highlight annot.ToggleHidingOnMouse annot.setHighlightType
annot.Accepted annot.HighlightType annot.Underline annot.setModificationDate
annot.Beveled annot.Inset annot.Unmarked annot.setUniqueName
annot.Cancelled annot.LineEffect annot.author annot.store
annot.Cloudy annot.LineStyle annot.boundary annot.subType
annot.Completed annot.Marked annot.contents annot.uniqueName
我正在使用以下软件包:
python -V
Python 3.4.3
popplerqt4.version()
(0, 24, 0)
popplerqt4.poppler_version()
(0, 30, 0)