pdfrw
pdfrw copied to clipboard
Boolean values in PdfDict
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.
I think you want to see is #37
So for now you can use:
writer.trailer.Root.ViewerPreferences = PdfDict(FitWindow=PdfObject('true'))