}
public static PdfViewerPreferencesImp getViewerPreferences(PdfDictionary catalog) {
PdfViewerPreferencesImp preferences = new PdfViewerPreferencesImp();
int prefs = 0;
PdfName name = null;
// page layout
PdfObject obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.PAGELAYOUT));
if (obj != null && obj.isName()) {
name = (PdfName) obj;
if (name.equals(PdfName.SINGLEPAGE))
prefs |= PdfWriter.PageLayoutSinglePage;
else if (name.equals(PdfName.ONECOLUMN))
prefs |= PdfWriter.PageLayoutOneColumn;
else if (name.equals(PdfName.TWOCOLUMNLEFT))
prefs |= PdfWriter.PageLayoutTwoColumnLeft;
else if (name.equals(PdfName.TWOCOLUMNRIGHT))
prefs |= PdfWriter.PageLayoutTwoColumnRight;
else if (name.equals(PdfName.TWOPAGELEFT))
prefs |= PdfWriter.PageLayoutTwoPageLeft;
else if (name.equals(PdfName.TWOPAGERIGHT))
prefs |= PdfWriter.PageLayoutTwoPageRight;
}
// page mode
obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.PAGEMODE));
if (obj != null && obj.isName()) {
name = (PdfName) obj;
if (name.equals(PdfName.USENONE))
prefs |= PdfWriter.PageModeUseNone;
else if (name.equals(PdfName.USEOUTLINES))
prefs |= PdfWriter.PageModeUseOutlines;
else if (name.equals(PdfName.USETHUMBS))
prefs |= PdfWriter.PageModeUseThumbs;
else if (name.equals(PdfName.USEOC))
prefs |= PdfWriter.PageModeUseOC;
else if (name.equals(PdfName.USEATTACHMENTS))
prefs |= PdfWriter.PageModeUseAttachments;
}
// set page layout and page mode preferences
preferences.setViewerPreferences(prefs);
// other preferences