File tree Expand file tree Collapse file tree
Libraries/Itext/Sources/Internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,7 +179,29 @@ private void SetMetadata(Metadata src, PdfDocument dest)
179179 . SetCreator ( src . Creator ) ;
180180
181181 var pl = src . Options . ToPageLayout ( ) ;
182- if ( pl != ViewerOption . None ) _ = dest . GetCatalog ( ) . SetPageLayout ( new ( pl . ToName ( ) ) ) ;
182+ if ( pl != ViewerOption . None )
183+ {
184+ PdfName pageLayout = new ( pl . ToName ( ) ) ;
185+ _ = dest . GetCatalog ( ) . SetPageLayout ( pageLayout ) ;
186+
187+ var viewerPreferences = dest . GetCatalog ( ) . GetViewerPreferences ( ) ;
188+ if ( viewerPreferences is null )
189+ {
190+ // Init ViewerPreferences
191+ viewerPreferences = new PdfViewerPreferences ( ) ;
192+ dest . GetCatalog ( ) . SetViewerPreferences ( viewerPreferences ) ;
193+ }
194+
195+ // Add Direction to ViewerPreferences
196+ if ( pl == ViewerOption . TwoColumnRight || pl == ViewerOption . TwoPageRight )
197+ {
198+ viewerPreferences . SetDirection ( PdfViewerPreferences . PdfViewerPreferencesConstants . RIGHT_TO_LEFT ) ;
199+ }
200+ else
201+ {
202+ viewerPreferences . SetDirection ( PdfViewerPreferences . PdfViewerPreferencesConstants . LEFT_TO_RIGHT ) ;
203+ }
204+ }
183205
184206 var pm = src . Options . ToPageMode ( ) ;
185207 if ( pm != ViewerOption . None ) _ = dest . GetCatalog ( ) . SetPageMode ( new ( pm . ToName ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments