PdfViewerPreferences extends PdfObjectWrapper<PdfDictionary> { public PdfViewerPreferences setDuplex(PdfViewerPreferencesConstants duplex) { switch (duplex) { case SIMPLEX: put(PdfName.Duplex, PdfName.Simplex); break; case DUPLEX_FLIP_SHORT_EDGE: put(PdfName.Duplex, PdfName.DuplexFlipShortEdge); break; case DUPLEX_FLIP_LONG_EDGE: put(PdfName.Duplex, PdfName.DuplexFlipLongEdge); break; default: } return this; } PdfViewerPreferences();  PdfViewerPreferences(PdfDictionary pdfObject); PdfViewerPreferences setHideToolbar(boolean hideToolbar); PdfViewerPreferences setHideMenubar(boolean hideMenubar); PdfViewerPreferences setHideWindowUI(boolean hideWindowUI); PdfViewerPreferences setFitWindow(boolean fitWindow); PdfViewerPreferences setCenterWindow(boolean centerWindow); PdfViewerPreferences setDisplayDocTitle(boolean displayDocTitle); PdfViewerPreferences setNonFullScreenPageMode(PdfViewerPreferencesConstants nonFullScreenPageMode); PdfViewerPreferences setDirection(PdfViewerPreferencesConstants direction); PdfViewerPreferences setViewArea(PdfViewerPreferencesConstants pageBoundary); PdfViewerPreferences setViewClip(PdfViewerPreferencesConstants pageBoundary); PdfViewerPreferences setPrintArea(PdfViewerPreferencesConstants pageBoundary); PdfViewerPreferences setPrintClip(PdfViewerPreferencesConstants pageBoundary); PdfViewerPreferences setPrintScaling(PdfViewerPreferencesConstants printScaling); PdfViewerPreferences setDuplex(PdfViewerPreferencesConstants duplex); PdfViewerPreferences setPickTrayByPDFSize(boolean pickTrayByPdfSize); PdfViewerPreferences setPrintPageRange(int[] printPageRange); PdfViewerPreferences setNumCopies(int numCopies); PdfViewerPreferences setEnforce(PdfArray enforce); PdfArray getEnforce(); PdfViewerPreferences put(PdfName key, PdfObject value);  }
@Test public void duplexTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); Assert.assertEquals(0, dictionary.size()); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); Assert.assertEquals(0, dictionary.size()); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.SIMPLEX); Assert.assertEquals(1, dictionary.size()); Assert.assertEquals(PdfName.Simplex, dictionary.get(PdfName.Duplex)); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.DUPLEX_FLIP_LONG_EDGE); Assert.assertEquals(1, dictionary.size()); Assert.assertEquals(PdfName.DuplexFlipLongEdge, dictionary.get(PdfName.Duplex)); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.DUPLEX_FLIP_SHORT_EDGE); Assert.assertEquals(1, dictionary.size()); Assert.assertEquals(PdfName.DuplexFlipShortEdge, dictionary.get(PdfName.Duplex)); }