iText: setting PDF view defaults

泪湿孤枕 提交于 2019-12-23 16:17:55

问题


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.



来源:https://stackoverflow.com/questions/3186906/itext-setting-pdf-view-defaults

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!