pdfrw icon indicating copy to clipboard operation
pdfrw copied to clipboard

Boolean values in PdfDict

Open mikaraunio opened this issue 7 years ago • 1 comments

I wanted to set ViewerPreferences in my output so as to get: /ViewerPreferences <</FitWindow true>>.

I first tried:

writer.trailer.Root.ViewerPreferences = PdfDict(FitWindow=True)

But this produces True instead of true in the output. And of course, FitWindow='true' gives (true).

I looked at the code but didn't find any obvious clues. I finally got it working with the following kludge:

class PdfTrue(object):
    def __str__(self):
        return "true"

writer.trailer.Root.ViewerPreferences = PdfDict(FitWindow=PdfTrue())

I feel there should be a more canonical way to achieve this.

mikaraunio avatar Mar 03 '18 14:03 mikaraunio

I think you want to see is #37 So for now you can use: writer.trailer.Root.ViewerPreferences = PdfDict(FitWindow=PdfObject('true'))

PeterSlezak avatar Nov 27 '18 19:11 PeterSlezak