當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfReader.SelectPages方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfReader.SelectPages方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfReader.SelectPages方法的具體用法?C# PdfReader.SelectPages怎麽用?C# PdfReader.SelectPages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfReader的用法示例。


在下文中一共展示了PdfReader.SelectPages方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddDocument

 public void AddDocument(PdfReader reader, List<int> pagesToKeep) {
     if (indirectMap.ContainsKey(reader)) {
         throw new ArgumentException(MessageLocalization.GetComposedMessage("document.1.has.already.been.added", reader.ToString()));
     }
     reader.SelectPages(pagesToKeep);
     AddDocument(reader);
 }
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例2: Write

// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      MovieTemplates mt = new MovieTemplates();
      byte[] pdf = Utility.PdfBytes(mt);
      PdfReader reader = new PdfReader(pdf);
      using (ZipFile zip = new ZipFile()) {
        reader.SelectPages("4-8");
        zip.AddEntry(RESULT1, ManipulateWithStamper(reader));
/*
 * can't figure out __WHY__, but if i don't reset the reader the example
 * will __NOT__ work!
 */
        reader = new PdfReader(pdf);
        reader.SelectPages("4-8"); 
        zip.AddEntry(RESULT2, ManipulateWithCopy(reader));       
        zip.AddEntry(Utility.ResultFileName(mt.ToString() + ".pdf"), pdf);
        zip.Save(stream);
      }
    }
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例3: Write

 // --------------------------------------------------------------------------- 
 public void Write(Stream stream)
 {
     using (ZipFile zip = new ZipFile())
     {
         Stationery s = new Stationery();
         StampStationery ss = new StampStationery();
         byte[] stationery = s.CreateStationary();
         byte[] sStationery = ss.ManipulatePdf(
           ss.CreatePdf(), stationery
         );
         byte[] insertPages = ManipulatePdf(sStationery, stationery);
         zip.AddEntry(RESULT1, insertPages);
         // reorder the pages in the PDF
         PdfReader reader = new PdfReader(insertPages);
         reader.SelectPages("3-41,1-2");
         using (MemoryStream ms = new MemoryStream())
         {
             using (PdfStamper stamper = new PdfStamper(reader, ms))
             {
             }
             zip.AddEntry(RESULT2, ms.ToArray());
         }
         zip.AddEntry(Utility.ResultFileName(s.ToString() + ".pdf"), stationery);
         zip.AddEntry(Utility.ResultFileName(ss.ToString() + ".pdf"), sStationery);
         zip.Save(stream);
     }
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:28,代碼來源:InsertPages.cs

示例4: Test

 public void Test()
 {
     PdfReader reader = new PdfReader(dataFile);
     try
     {
         reader.SelectPages("4-8");
         ManipulateWithStamper(reader);
         ManipulateWithCopy(reader);
     }
     finally
     {
         reader.Close();
     }
 }
開發者ID:smartleos,項目名稱:itextsharp,代碼行數:14,代碼來源:PdfReaderSelectPagesTest.cs

示例5: AddDocument

 internal void AddDocument(PdfReader reader, ArrayList pagesToKeep)
 {
     if (!readers2intrefs.ContainsKey(reader) && reader.Tampered)
         throw new DocumentException("The document was reused.");
     reader = new PdfReader(reader);
     reader.SelectPages(pagesToKeep);
     if (reader.NumberOfPages == 0)
         return;
     reader.Tampered = false;
     AddDocument(reader);
 }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:11,代碼來源:PdfCopyFieldsImp.cs

示例6: ProcessPdf

        void ProcessPdf(string path)
        {
            using (var reader = new PdfReader(path))
            {
                // need this call to parse page numbers
                reader.ConsolidateNamedDestinations();

                var bookmarks = ParseBookMarks(SimpleBookmark.GetBookmark(reader));
                for (int i = 0; i < bookmarks.Count; ++i)
                {
                    int page = bookmarks[i].PageNumberInteger;
                    int nextPage = i + 1 < bookmarks.Count
                        // if not top of page will be missing content
                        ? bookmarks[i + 1].PageNumberInteger - 1 

                        /* alternative is to potentially add redundant content:
                        ? bookmarks[i + 1].PageNumberInteger
                        */

                        : reader.NumberOfPages;
                    string range = string.Format("{0}-{1}", page, nextPage);

                    // DEMO!
                    if (i < 1000)
                    {
                        var outputPath = Path.Combine(OUTPUT_DIR, bookmarks[i].GetFileName());
                        using (var readerCopy = new PdfReader(reader))
                        {
                            var number = bookmarks[i].Number;
                            readerCopy.SelectPages(range);
                            using (FileStream stream = new FileStream(outputPath, FileMode.Create))
                            {
                                using (var document = new Document())
                                {
                                    using (var copy = new PdfCopy(document, stream))
                                    {
                                        document.Open();
                                        int n = readerCopy.NumberOfPages;
                                        for (int j = 0; j < n; )
                                        {
                                            copy.AddPage(copy.GetImportedPage(readerCopy, ++j));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
開發者ID:kuujinbo,項目名稱:StackOverflow.iTextSharp,代碼行數:50,代碼來源:ExtractChapters.cs

示例7: MakePage

 /// <summary>
 /// Makes a single PDF page by reference.
 /// </summary>
 /// <param name="filePath">The file path.</param>
 /// <param name="x">The running record total.</param>
 /// <param name="dt">DataTable contaning report query.</param>
 /// <param name="bdt">DataTable containing the report detail query.</param>
 /// <param name="verticalSpacing">The vertical spacing between each line in the report detail.</param>
 /// <param name="rpp">Records Per Page.</param>
 /// <param name="page">Current Page to read from.</param>
 /// <param name="currentPage">Current page to write to.</param>
 /// <param name="totalPages">The total number of pages.</param>
 /// <param name="queryArguments">The query arguments.</param>
 /// <returns>rendered pdf page</returns>
 private static MemoryStream MakePage(string filePath, ref int x, ref DataTable dt, ref DataTable bdt,
 int verticalSpacing, int rpp, int page, int currentPage, int totalPages, Dictionary<string, object> queryArguments)
 {
     ("FUNCTION /w binaryStream makePage").Debug(10);
     MemoryStream ms = new MemoryStream();
     PdfReader reader = new PdfReader(filePath);
     PdfStamper stamp = new PdfStamper(reader, ms);
     Dictionary<string, AField> docFields = new Dictionary<string, AField>();
     reader.SelectPages(page.ToString());
     float top = 0;
     for(var y = 0; rpp > y; y++) {
         if(y + x > bdt.Rows.Count - 1) { break; };
         foreach(string fieldKey in stamp.AcroFields.Fields.Keys) {
             if(fieldKey.StartsWith(">>") || fieldKey.StartsWith(">>image")) {
                 WriteField(x + y, 1, top, fieldKey, ref stamp, ref docFields, currentPage, totalPages, bdt, queryArguments);
             }
         }
         top -= verticalSpacing;
     }
     foreach(string fieldKey in stamp.AcroFields.Fields.Keys) {
         if(
         (fieldKey.StartsWith(">") && (!fieldKey.StartsWith(">>"))) ||
         (fieldKey.StartsWith(">image") && (!fieldKey.StartsWith(">>image"))) || fieldKey.StartsWith("_page")
         ) {
             WriteField(0, 0, 0, fieldKey, ref stamp, ref docFields, currentPage, totalPages, dt, queryArguments);
         }
     }
     reader.RemoveFields();
     foreach(KeyValuePair<string, AField> f in docFields) {
         Rectangle rect = f.Value.Rect;
         string value = f.Value.Value;
         TextField field = new TextField(stamp.Writer, rect, f.Key);
         field.DefaultText = value;
         field.FieldName = f.Key;
         field.Options = iTextSharp.text.pdf.TextField.MULTILINE;
         stamp.AddAnnotation(field.GetTextField(), 1);
     }
     stamp.Close();
     reader.Close();
     reader = new PdfReader(ms.GetBuffer());
     MemoryStream os = new MemoryStream();
     stamp = new PdfStamper(reader, os);
     WriteAFieldCollection(ref stamp, docFields, filePath);
     reader.RemoveFields();
     stamp.Close();
     reader.Close();
     return os;
 }
開發者ID:CorbinDallas,項目名稱:Rendition,代碼行數:62,代碼來源:Pdf.cs

示例8: GetSecondPage

 private PdfReader GetSecondPage()
 {
     PdfReader PDF = new PdfReader(PDFBytes);
     PDF.RemoveUsageRights();
     PDF.SelectPages("2");
     return PDF;
 }
開發者ID:JohnPAguirre,項目名稱:324th-HHC-LIK-Paperwork-Generator,代碼行數:7,代碼來源:Generate324thLIK.cs


注:本文中的iTextSharp.text.pdf.PdfReader.SelectPages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。