I create a PDF with iText7, which should not show the toolbar. But it should display the area with the bookmarks/outlines.
PdfViewerPreferences pref = new PdfViewerPreferences();
pref.SetHideToolbar(true); // works
pref.SetNonFullScreenPageMode(PdfViewerPreferences.PdfViewerPreferencesConstants.USE_OUTLINES); // doesn't work
pdfDocument.GetCatalog().SetViewerPreferences(pref);
Documentation of SetNonFullScreenPageMode
clearly says the following:
This entry is meaningful only if the value of the PageMode entry in the Catalog dictionary is FullScreen
Thus you need to also add the following line in order for your configuration to become active:
pdfDocument.GetCatalog().SetPageMode(PdfName.FullScreen);
However, this will make Acrobat ask you to enter full screen mode on opening the PDF and in full screen mode nothing is shown but the page content.
What you are really looking for is setting PageMode
to UseOutlines
:
pdfDocument.GetCatalog().SetPageMode(PdfName.UseOutlines);
Full code:
PdfViewerPreferences pref = new PdfViewerPreferences();
pref.SetHideToolbar(true);
pdfDocument.GetCatalog().SetViewerPreferences(pref);
pdfDocument.GetCatalog().SetPageMode(PdfName.UseOutlines);