Skip to content

Commit c28753b

Browse files
committed
Disable direction functionality temporarily
1 parent 09a0ef9 commit c28753b

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

Libraries/Itext/Sources/Internal/Writer.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,13 @@ private void SetMetadata(Metadata src, PdfDocument dest)
194194
catalog.SetViewerPreferences(vp);
195195
}
196196

197-
// Add Direction to ViewerPreferences
198-
var direction = layout == ViewerOption.TwoColumnRight || layout == ViewerOption.TwoPageRight ?
199-
PdfViewerPreferences.PdfViewerPreferencesConstants.RIGHT_TO_LEFT :
200-
PdfViewerPreferences.PdfViewerPreferencesConstants.LEFT_TO_RIGHT ;
201-
vp.SetDirection(direction);
197+
// TODO: Disable direction functionality (L2R/R2L) temporarily,
198+
// need more complicated modification such as adding a new name on the ViewerOption side.
199+
//
200+
// var direction = layout == ViewerOption.TwoColumnRight || layout == ViewerOption.TwoPageRight ?
201+
// PdfViewerPreferences.PdfViewerPreferencesConstants.RIGHT_TO_LEFT :
202+
// PdfViewerPreferences.PdfViewerPreferencesConstants.LEFT_TO_RIGHT ;
203+
// vp.SetDirection(direction);
202204
}
203205

204206
var mode = src.Options.ToPageMode();

Tests/Core/Sources/Itext/ItextWriterTest.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void SetMetadata(string value)
259259
Creator = value,
260260
Producer = value,
261261
Version = new PdfVersion(1, 5),
262-
Options = ViewerOption.TwoColumnLeft,
262+
Options = ViewerOption.SinglePage,
263263
};
264264

265265
using (var w = new DocumentWriter(new()))
@@ -282,6 +282,44 @@ public void SetMetadata(string value)
282282
Assert.That(m.Options, Is.EqualTo(cmp.Options));
283283
}
284284

285+
/* ----------------------------------------------------------------- */
286+
///
287+
/// SetMetadata
288+
///
289+
/// <summary>
290+
/// Test to set PDF page layout.
291+
/// </summary>
292+
///
293+
/* ----------------------------------------------------------------- */
294+
[TestCase(ViewerOption.SinglePage)]
295+
[TestCase(ViewerOption.OneColumn)]
296+
[TestCase(ViewerOption.TwoColumnLeft)]
297+
[TestCase(ViewerOption.TwoColumnRight)]
298+
[TestCase(ViewerOption.TwoPageLeft)]
299+
[TestCase(ViewerOption.TwoPageRight)]
300+
public void SetLayout(ViewerOption value)
301+
{
302+
var src = GetSource("SampleViewerOption.pdf");
303+
var dest = Path(Args(value));
304+
var op = new OpenOption { SaveMemory = true };
305+
var cmp = new Metadata
306+
{
307+
Version = new PdfVersion(1, 7),
308+
Options = value,
309+
};
310+
311+
using (var w = new DocumentWriter(new()))
312+
{
313+
w.Set(cmp);
314+
w.Add(new DocumentReader(src, "", op));
315+
w.Save(dest);
316+
}
317+
318+
using var r = new DocumentReader(dest, "", op);
319+
var m = r.Metadata;
320+
Assert.That(m.Options, Is.EqualTo(cmp.Options));
321+
}
322+
285323
/* ----------------------------------------------------------------- */
286324
///
287325
/// SetEncryption

0 commit comments

Comments
 (0)