Skip to content

setStyle method on HighlightAnnotation #10

@divico

Description

@divico
python -V
Python 3.4.3       

popplerqt4.version()
(0, 24, 0)

popplerqt4.poppler_version()
(0, 30, 0)

Hi all

I cannot figure out how to change the color of an existing HighlightAnnotation. I have a PDF document with existing HighlightAnnotations that I can retrieve for a given page with:

 In [1]: doc = popplerqt4.Poppler.Document.load('doc.pdf')
 In [2]: annotations = doc.page(0).annotations()

which gives me two annotations of type Highlight.

 In [3]: annotations
 Out[3]: 
 [<popplerqt4.HighlightAnnotation at 0x7f4cbc170948>,
  <popplerqt4.HighlightAnnotation at 0x7f4cbc170558>]

Now I can change the author or change the quads with respectively the setAuthor() and setHighlightQuads()methods. This works perfectly and it has the expected behavior when the document is saved (with pdfConverter()).

My question is, given annotations, what is the proper way to change the color of the highlight ? I've seen in a couple of c++ examples that they use annot->style().setColor( RED ); for instance. How can I access the style property of my annotations with python ? In my example I have only access to the attributes below. Thank you in advance for any hints !

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions