我想用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)
答案 0 :(得分:0)
解决方案在这里,应该很快在python-poppler-qt4&gt;中实现。 0.24.0