Ejemplo n.º 1
0
 /// <summary>
 /// Sets the default page orientation for all pages of the loaded file.
 /// @requires: loadedFile != null (file must be loaded)
 /// </summary>
 private void SetDefaultOrientation()
 {
     rotations = new List <PageOrientation>();
     for (int i = 0; i < loadedFile.PageCount; i++)
     {
         rotations.Add(PageOrientation.NoRotation());
     }
 }
Ejemplo n.º 2
0
        public void TestRotatePages(string inputFileName, string outputFilename, int expectedNumberOfPages)
        {
            PdfDocument      inputFile     = LoadTestFile(inputFileName);
            List <PageRange> relevantPages = new List <PageRange>();

            relevantPages.Add(PageRange.FromPattern(inputFile, "1,5"));
            relevantPages.Add(PageRange.FromPattern(inputFile, "3-4"));
            relevantPages.Add(PageRange.FromPattern(inputFile, "2-3"));
            relevantPages.Add(PageRange.FromPattern(inputFile, ""));

            List <ExportTask> exportTasks = new List <ExportTask>();

            exportTasks.Add(new ExportTask(relevantPages[0], new List <IPageTransformation>()
            {
                new PageRotation(PageOrientation.NoRotation())
            }));
            exportTasks.Add(new ExportTask(relevantPages[1], new List <IPageTransformation>()
            {
                new PageRotation(PageOrientation.UpsideDown())
            }));
            exportTasks.Add(new ExportTask(relevantPages[2], new PageRotation(PageOrientation.RotateRight())));
            exportTasks.Add(new ExportTask(relevantPages[3], new PageRotation(PageOrientation.NoRotation())));

            Stream       outputStream = new FileStream(outputFilename, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            PdfAssembler assembler    = new PdfAssembler(outputStream);

            foreach (var task in exportTasks)
            {
                assembler.AppendTask(task);
            }

            assembler.ExportFile();

            PdfDocument result = LoadTestFile(outputFilename);

            Assert.AreEqual(expectedNumberOfPages, result.GetNumberOfPages());
        }