iText: setting PDF view defaults

2019-07-01 14:40发布

问题:

I'm using iText for a bit of manipulating my PDFs through Java, and I'd like to make it so that a PDF default opens so that a single page fits in the window it opens, that this window is preferrably full screen, and that it has a thumbnail view on the lefthand side. I know other programs can set these view preferences, so I assume iText can, but I haven't figured out how or what part of the API I should be looking at. Do you have any suggestions?

Cheers

Nik

回答1:

You have to use the setViewPreferences of the PdfWriter class. Example:

writer.setViewerPreferences(PdfWriter.FitWindow 
  | PdfWriter.PageModeUseThumbs);

You can also selectively hide/show many element of the reader user interface, for example with the PdfWriter.HideToolbar flag; you can also show the document in fullscreen mode, that is very uiseful in some circumstances, with the PdfWriter.PageModeFullScreen flag. Flags ara all bit masks, so you have to use the | operator.



标签: java pdf itext