Shiva Nandan
Shiva Nandan

Reputation: 11

PDFMiner returns wrong RGB color and also returns INT value 0 or 1

LTTextHorizontal for this object.

When I iterate over LTChar in this way. char.graphicstate.ncolor it returns wrong RGB values when it is white it returns (1,1,1) and for other pdf it returns 0 or 1.

How can this be fixed?

for page_layout in extract_pages(scr_file):
        for element in page_layout:
            if isinstance(element, LTTextContainer):
                fontinfo = set()
                for text_line in element:
                    for character in text_line:
                        if isinstance(character, LTChar):
                            fontinfo.add(character.fontname)
                            fontinfo.add(character.size)
                            fontinfo.add(character.graphicstate.scolor)
                            fontinfo.add(character.graphicstate[text]([https://stackoverflow.com](https://stackoverflow.com))

Upvotes: -1

Views: 68

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54767

Colors in PDFs are floats running from 0 to 1, not integers from 0 to 255 as you seem to expect.

Upvotes: 0

Related Questions