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


C# PdfReader.GetPageNRelease方法代碼示例

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


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

示例1: ReadCompressedPdfTest1

 public virtual void ReadCompressedPdfTest1() {
     string filename = TestResourceUtils.GetResourceAsTempFile(TEST_RESOURCES_PATH, "readCompressedPdfTest1.pdf");
     PdfReader rdr = new PdfReader(filename);
     for (int i = 1; i <= rdr.NumberOfPages; i++) {
         PdfDictionary p = rdr.GetPageNRelease(i);
         Assert.AreEqual(PdfName.PAGE.ToString(), p.GetAsName(PdfName.TYPE).ToString());
     }
     rdr.Close();
 }
開發者ID:Niladri24dutta,項目名稱:itextsharp,代碼行數:9,代碼來源:PdfReaderTest.cs

示例2: AddDocument

 public void AddDocument(PdfReader reader) {
     if (indirectMap.ContainsKey(reader)) {
         throw new ArgumentException(MessageLocalization.GetComposedMessage("document.1.has.already.been.added", reader.ToString()));
     }
     if (!reader.IsOpenedWithFullPermissions)
         throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));
     if (mergeFields) {
         reader.ConsolidateNamedDestinations();
         reader.ShuffleSubsetNames();
         for (int i = 1; i <= reader.NumberOfPages; i++) {
             PdfDictionary page = reader.GetPageNRelease(i);
             if (page != null && page.Contains(PdfName.ANNOTS)) {
                 PdfArray annots = page.GetAsArray(PdfName.ANNOTS);
                 if (annots != null) {
                     for (int j = 0; j < annots.Size; j++) {
                         PdfDictionary annot = annots.GetAsDict(j);
                         if (annot != null)
                             annot.Put(annotId, new PdfNumber(++annotIdCnt));
                     }
                 }
             }
         }
         fields.Add(reader.AcroFields);
         UpdateCalculationOrder(reader);
     }
     bool tagged = PdfStructTreeController.CheckTagged(reader);
     mergeFieldsInternalCall = true;
     for (int i = 1; i <= reader.NumberOfPages; i++) {
         AddPage(GetImportedPage(reader, i, tagged && this.tagged));
     }
     mergeFieldsInternalCall = false;
 }
開發者ID:,項目名稱:,代碼行數:32,代碼來源:

示例3: AddDocument

 virtual public void AddDocument(PdfReader reader) {
     if (!document.IsOpen()) {
         throw new DocumentException(MessageLocalization.GetComposedMessage("the.document.is.not.open.yet.you.can.only.add.meta.information"));
     }
     if (indirectMap.ContainsKey(reader)) {
         throw new ArgumentException(MessageLocalization.GetComposedMessage("document.1.has.already.been.added", reader.ToString()));
     }
     if (!reader.IsOpenedWithFullPermissions)
         throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));
     if (mergeFields) {
         reader.ConsolidateNamedDestinations();
         reader.ShuffleSubsetNames();
         for (int i = 1; i <= reader.NumberOfPages; i++) {
             PdfDictionary page = reader.GetPageNRelease(i);
             if (page != null && page.Contains(PdfName.ANNOTS)) {
                 PdfArray annots = page.GetAsArray(PdfName.ANNOTS);
                 if (annots != null) {
                     for (int j = 0; j < annots.Size; j++) {
                         PdfDictionary annot = annots.GetAsDict(j);
                         if (annot != null)
                             annot.Put(annotId, new PdfNumber(++annotIdCnt));
                     }
                 }
             }
         }
         AcroFields acro = reader.AcroFields;
         // when a document with NeedAppearances is encountered, the flag is set
         // in the resulting document.
         bool needapp = !acro.GenerateAppearances;
         if (needapp)
             needAppearances = true;
         fields.Add(reader.AcroFields);
         UpdateCalculationOrder(reader);
     }
     bool tagged = this.tagged && PdfStructTreeController.CheckTagged(reader);
     mergeFieldsInternalCall = true;
     for (int i = 1; i <= reader.NumberOfPages; i++) {
         AddPage(GetImportedPage(reader, i, tagged));
     }
     mergeFieldsInternalCall = false;
 }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:41,代碼來源:PdfCopy.cs

示例4: CopyDocumentFields

        /**
         * Copy document fields to a destination document.
         * @param reader a document where fields are copied from.
         * @throws DocumentException
         * @throws IOException
         */
        public virtual void CopyDocumentFields(PdfReader reader) {
            if (!document.IsOpen()) {
                throw new DocumentException(
                    MessageLocalization.GetComposedMessage("the.document.is.not.open.yet.you.can.only.add.meta.information"));
            }

            if (indirectMap.ContainsKey(reader)) {
                throw new ArgumentException(MessageLocalization.GetComposedMessage("document.1.has.already.been.added",
                    reader.ToString()));
            }

            if (!reader.IsOpenedWithFullPermissions)
                throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));

            if (!mergeFields)
                throw new ArgumentException(
                    MessageLocalization.GetComposedMessage(
                        "1.method.can.be.only.used.in.mergeFields.mode.please.use.addDocument", "copyDocumentFields"));

            indirects = new Dictionary<RefKey, IndirectReferences>();
            indirectMap[reader] = indirects;

            reader.ConsolidateNamedDestinations();
            reader.ShuffleSubsetNames();
            if (tagged && PdfStructTreeController.CheckTagged(reader)) {
                structTreeRootReference = (PRIndirectReference) reader.Catalog.Get(PdfName.STRUCTTREEROOT);
                if (structTreeController != null) {
                    if (reader != structTreeController.reader)
                        structTreeController.SetReader(reader);
                } else {
                    structTreeController = new PdfStructTreeController(reader, this);
                }
            }

            IList<PdfObject> annotationsToBeCopied = new List<PdfObject>();

            for (int i = 1; i <= reader.NumberOfPages; i++) {
                PdfDictionary page = reader.GetPageNRelease(i);
                if (page != null && page.Contains(PdfName.ANNOTS)) {
                    PdfArray annots = page.GetAsArray(PdfName.ANNOTS);
                    if (annots != null && annots.Size > 0) {
                        if (importedPages.Count < i)
                            throw new DocumentException(
                                MessageLocalization.GetComposedMessage("there.are.not.enough.imported.pages.for.copied.fields"));
                        indirectMap[reader][new RefKey(reader.pageRefs.GetPageOrigRef(i))] = new IndirectReferences(pageReferences[i - 1]);
                        for (int j = 0; j < annots.Size; j++) {
                            PdfDictionary annot = annots.GetAsDict(j);
                            if (annot != null) {
                                annot.Put(annotId, new PdfNumber(++annotIdCnt));
                                annotationsToBeCopied.Add(annots[j]);
                            }
                        }
                    }
                }
            }

            foreach (PdfObject annot in annotationsToBeCopied) {
                CopyObject(annot);
            }

            if (tagged && structTreeController != null)
                structTreeController.AttachStructTreeRootKids(null);

            AcroFields acro = reader.AcroFields;
            bool needapp = !acro.GenerateAppearances;
            if (needapp)
                needAppearances = true;
            fields.Add(acro);
            UpdateCalculationOrder(reader);
            structTreeRootReference = null;
        }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:77,代碼來源:PdfCopy.cs


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