1//
2// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
3//
4
5using System;
6using pdftron;
7using pdftron.Common;
8using pdftron.Filters;
9using pdftron.SDF;
10using pdftron.PDF;
11
12using NUnit.Framework;
13
14namespace MiscellaneousSamples
15{
16 /// <summary>
17 /// Summary description for Class1.
18 /// </summary>
19 [TestFixture]
20 public class RectTest
21 {
22
23 /// <summary>
24 /// The main entry point for the application.
25 /// </summary>
26 [Test]
27 public static void Sample()
28 {
29 // Relative path to the folder containing test files.
30 const string input_path = "TestFiles/";
31
32 Console.WriteLine("_______________________________________________");
33 Console.WriteLine("Opening the input pdf...");
34
35 try // Test - Adjust the position of content within the page.
36 {
37 using (PDFDoc input_doc = new PDFDoc(Utils.GetAssetTempFile(input_path + "tiger.pdf")))
38 {
39 input_doc.InitSecurityHandler();
40
41 Page pg = input_doc.GetPage(1);
42 Rect media_box = pg.GetMediaBox();
43
44 media_box.x1 -= 200; // translate the page 200 units (1 uint = 1/72 inch)
45 media_box.x2 -= 200;
46
47 media_box.Update();
48
49 input_doc.Save(Utils.CreateExternalFile("tiger_shift.pdf"), 0);
50 }
51
52 Console.WriteLine("Done. Result saved in tiger_shift...");
53 }
54 catch (PDFNetException e)
55 {
56 Console.WriteLine(e.Message);
57 Assert.True(false);
58 }
59 }
60 }
61}