Bläddra i källkod

compdfkit(win) - PDFPage Samples: Array List -> List<int>

liuaoran 1 år sedan
förälder
incheckning
7c384211fe
1 ändrade filer med 8 tillägg och 6 borttagningar
  1. 8 6
      Demo/Examples/Samples/PDFPageTest/CS/PDFPageTest.cs

+ 8 - 6
Demo/Examples/Samples/PDFPageTest/CS/PDFPageTest.cs

@@ -219,12 +219,15 @@ namespace PDFPageTest
         /// <param name="document">Regular five page document</param> 
         static private bool RemovePages(CPDFDocument document)
         {
-            ArrayList arr = new ArrayList();
+            List<int> pageNumbersToRemove = new List<int>();
+
             for (int i = 1; i < document.PageCount; i += 2)
             {
-                arr.Add(i);
+                pageNumbersToRemove.Add(i);
             }
-            document.RemovePages((int[])arr.ToArray(typeof(int)));
+
+            document.RemovePages(pageNumbersToRemove.ToArray());
+             
 
             string path = outputPath + "\\RemoveEvenPagesTest.pdf";
             if (!document.WriteToFilePath(path))
@@ -259,9 +262,8 @@ namespace PDFPageTest
         /// <param name="document">Regular five page document</param>
         static private bool RepalcePages(CPDFDocument document)
         {
-            int[] pageArr = new int[1];
-            pageArr[0] = 0;
-            document.RemovePages(pageArr);
+            List<int> pageList = new List<int>() { 0 }; 
+            document.RemovePages(pageList.ToArray());
             CPDFDocument documentForInsert = CPDFDocument.InitWithFilePath("Text.pdf");
             document.ImportPagesAtIndex(documentForInsert, "1", 0);
             string path = outputPath + "\\RepalcePagesTest.pdf";