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


C# PdfDictionary.GetAsArray方法代碼示例

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


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

示例1: DecodeGenericDictionary

 public void DecodeGenericDictionary(PdfDictionary merged, BaseField tx)
 {
     int flags = 0;
     // the text size and color
     PdfString da = merged.GetAsString(PdfName.DA);
     if (da != null) {
         Object[] dab = SplitDAelements(da.ToUnicodeString());
         if (dab[DA_SIZE] != null)
             tx.FontSize = (float)dab[DA_SIZE];
         if (dab[DA_COLOR] != null)
             tx.TextColor = (Color)dab[DA_COLOR];
         if (dab[DA_FONT] != null) {
             PdfDictionary font = merged.GetAsDict(PdfName.DR);
             if (font != null) {
                 font = font.GetAsDict(PdfName.FONT);
                 if (font != null) {
                     PdfObject po = font.Get(new PdfName((String)dab[DA_FONT]));
                     if (po != null && po.Type == PdfObject.INDIRECT) {
                         PRIndirectReference por = (PRIndirectReference)po;
                         BaseFont bp = new DocumentFont((PRIndirectReference)po);
                         tx.Font = bp;
                         int porkey = por.Number;
                         BaseFont porf = (BaseFont)extensionFonts[porkey];
                         if (porf == null) {
                             if (!extensionFonts.ContainsKey(porkey)) {
                                 PdfDictionary fo = (PdfDictionary)PdfReader.GetPdfObject(po);
                                 PdfDictionary fd = fo.GetAsDict(PdfName.FONTDESCRIPTOR);
                                 if (fd != null) {
                                     PRStream prs = (PRStream)PdfReader.GetPdfObject(fd.Get(PdfName.FONTFILE2));
                                     if (prs == null)
                                         prs = (PRStream)PdfReader.GetPdfObject(fd.Get(PdfName.FONTFILE3));
                                     if (prs == null) {
                                         extensionFonts[porkey] = null;
                                     }
                                     else {
                                         try {
                                             porf = BaseFont.CreateFont("font.ttf", BaseFont.IDENTITY_H, true, false, PdfReader.GetStreamBytes(prs), null);
                                         }
                                         catch {
                                         }
                                         extensionFonts[porkey] = porf;
                                     }
                                 }
                             }
                         }
                         if (tx is TextField)
                             ((TextField)tx).ExtensionFont = porf;
                     }
                     else {
                         BaseFont bf = (BaseFont)localFonts[dab[DA_FONT]];
                         if (bf == null) {
                             String[] fn = (String[])stdFieldFontNames[dab[DA_FONT]];
                             if (fn != null) {
                                 try {
                                     String enc = "winansi";
                                     if (fn.Length > 1)
                                         enc = fn[1];
                                     bf = BaseFont.CreateFont(fn[0], enc, false);
                                     tx.Font = bf;
                                 }
                                 catch {
                                     // empty
                                 }
                             }
                         }
                         else
                             tx.Font = bf;
                     }
                 }
             }
         }
     }
     //rotation, border and backgound color
     PdfDictionary mk = merged.GetAsDict(PdfName.MK);
     if (mk != null) {
         PdfArray ar = mk.GetAsArray(PdfName.BC);
         Color border = GetMKColor(ar);
         tx.BorderColor = border;
         if (border != null)
             tx.BorderWidth = 1;
         ar = mk.GetAsArray(PdfName.BG);
         tx.BackgroundColor = GetMKColor(ar);
         PdfNumber rotation = mk.GetAsNumber(PdfName.R);
         if (rotation != null)
             tx.Rotation = rotation.IntValue;
     }
     //flags
     PdfNumber nfl = merged.GetAsNumber(PdfName.F);
     flags = 0;
     tx.Visibility = BaseField.VISIBLE_BUT_DOES_NOT_PRINT;
     if (nfl != null) {
         flags = nfl.IntValue;
         if ((flags & PdfFormField.FLAGS_PRINT) != 0 && (flags & PdfFormField.FLAGS_HIDDEN) != 0)
             tx.Visibility = BaseField.HIDDEN;
         else if ((flags & PdfFormField.FLAGS_PRINT) != 0 && (flags & PdfFormField.FLAGS_NOVIEW) != 0)
             tx.Visibility = BaseField.HIDDEN_BUT_PRINTABLE;
         else if ((flags & PdfFormField.FLAGS_PRINT) != 0)
             tx.Visibility = BaseField.VISIBLE;
     }
     //multiline
//.........這裏部分代碼省略.........
開發者ID:JamieMellway,項目名稱:iTextSharpLGPL-Monotouch,代碼行數:101,代碼來源:AcroFields.cs

示例2: FillFontDesc

 private void FillFontDesc(PdfDictionary fontDesc) {
     if (fontDesc == null)
         return;
     PdfNumber v = fontDesc.GetAsNumber(PdfName.ASCENT);
     if (v != null)
         Ascender = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.CAPHEIGHT);
     if (v != null)
         CapHeight = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.DESCENT);
     if (v != null)
         Descender = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.ITALICANGLE);
     if (v != null)
         ItalicAngle = v.FloatValue;
     PdfArray bbox = fontDesc.GetAsArray(PdfName.FONTBBOX);
     if (bbox != null) {
         llx = bbox.GetAsNumber(0).FloatValue;
         lly = bbox.GetAsNumber(1).FloatValue;
         urx = bbox.GetAsNumber(2).FloatValue;
         ury = bbox.GetAsNumber(3).FloatValue;
         if (llx > urx) {
             float t = llx;
             llx = urx;
             urx = t;
         }
         if (lly > ury) {
             float t = lly;
             lly = ury;
             ury = t;
         }
     }
 }
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例3: GetAppearance

 internal PdfAppearance GetAppearance(PdfDictionary merged, String text, String fieldName)
 {
     topFirst = 0;
     TextField tx = null;
     if (fieldCache == null || !fieldCache.ContainsKey(fieldName)) {
         tx = new TextField(writer, null, null);
         tx.SetExtraMargin(extraMarginLeft, extraMarginTop);
         tx.BorderWidth = 0;
         tx.SubstitutionFonts = substitutionFonts;
         DecodeGenericDictionary(merged, tx);
         //rect
         PdfArray rect = merged.GetAsArray(PdfName.RECT);
         Rectangle box = PdfReader.GetNormalizedRectangle(rect);
         if (tx.Rotation == 90 || tx.Rotation == 270)
             box = box.Rotate();
         tx.Box = box;
         if (fieldCache != null)
             fieldCache[fieldName] = tx;
     }
     else {
         tx = (TextField)fieldCache[fieldName];
         tx.Writer = writer;
     }
     PdfName fieldType = merged.GetAsName(PdfName.FT);
     if (PdfName.TX.Equals(fieldType)) {
         tx.Text = text;
         return tx.GetAppearance();
     }
     if (!PdfName.CH.Equals(fieldType))
         throw new DocumentException("An appearance was requested without a variable text field.");
     PdfArray opt = merged.GetAsArray(PdfName.OPT);
     int flags = 0;
     PdfNumber nfl = merged.GetAsNumber(PdfName.FF);
     if (nfl != null)
         flags = nfl.IntValue;
     if ((flags & PdfFormField.FF_COMBO) != 0 && opt == null) {
         tx.Text = text;
         return tx.GetAppearance();
     }
     if (opt != null) {
         String[] choices = new String[opt.Size];
         String[] choicesExp = new String[opt.Size];
         for (int k = 0; k < opt.Size; ++k) {
             PdfObject obj = opt[k];
             if (obj.IsString()) {
                     choices[k] = choicesExp[k] = ((PdfString)obj).ToUnicodeString();
             }
             else {
                 PdfArray a = (PdfArray) obj;
                 choicesExp[k] = a.GetAsString(0).ToUnicodeString();
                 choices[k] = a.GetAsString(1).ToUnicodeString();
             }
         }
         if ((flags & PdfFormField.FF_COMBO) != 0) {
             for (int k = 0; k < choices.Length; ++k) {
                 if (text.Equals(choicesExp[k])) {
                     text = choices[k];
                     break;
                 }
             }
             tx.Text = text;
             return tx.GetAppearance();
         }
         int idx = 0;
         for (int k = 0; k < choicesExp.Length; ++k) {
             if (text.Equals(choicesExp[k])) {
                 idx = k;
                 break;
             }
         }
         tx.Choices = choices;
         tx.ChoiceExports = choicesExp;
         tx.ChoiceSelection = idx;
     }
     PdfAppearance app = tx.GetListAppearance();
     topFirst = tx.TopFirst;
     return app;
 }
開發者ID:JamieMellway,項目名稱:iTextSharpLGPL-Monotouch,代碼行數:78,代碼來源:AcroFields.cs

示例4: UpdateByteRange

 private void UpdateByteRange(PdfPKCS7 pkcs7, PdfDictionary v)
 {
     PdfArray b = v.GetAsArray(PdfName.BYTERANGE);
     RandomAccessFileOrArray rf = reader.SafeFile;
     try {
         rf.ReOpen();
         byte[] buf = new byte[8192];
         for (int k = 0; k < b.Size; ++k) {
             int start = b.GetAsNumber(k).IntValue;
             int length = b.GetAsNumber(++k).IntValue;
             rf.Seek(start);
             while (length > 0) {
                 int rd = rf.Read(buf, 0, Math.Min(length, buf.Length));
                 if (rd <= 0)
                     break;
                 length -= rd;
                 pkcs7.Update(buf, 0, rd);
             }
         }
     }
     finally {
         try{rf.Close();}catch{}
     }
 }
開發者ID:JamieMellway,項目名稱:iTextSharpLGPL-Monotouch,代碼行數:24,代碼來源:AcroFields.cs

示例5: FillFontDesc

 private void FillFontDesc(PdfDictionary fontDesc) {
     if (fontDesc == null)
         return;
     PdfNumber v = fontDesc.GetAsNumber(PdfName.ASCENT);
     if (v != null)
         Ascender = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.CAPHEIGHT);
     if (v != null)
         CapHeight = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.DESCENT);
     if (v != null)
         Descender = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.ITALICANGLE);
     if (v != null)
         ItalicAngle = v.FloatValue;
     v = fontDesc.GetAsNumber(PdfName.FONTWEIGHT);
     if (v != null) {
         fontWeight = v.FloatValue;
     }
     PdfArray bbox = fontDesc.GetAsArray(PdfName.FONTBBOX);
     if (bbox != null) {
         llx = bbox.GetAsNumber(0).FloatValue;
         lly = bbox.GetAsNumber(1).FloatValue;
         urx = bbox.GetAsNumber(2).FloatValue;
         ury = bbox.GetAsNumber(3).FloatValue;
         if (llx > urx) {
             float t = llx;
             llx = urx;
             urx = t;
         }
         if (lly > ury) {
             float t = lly;
             lly = ury;
             ury = t;
         }
     }
     float maxAscent = Math.Max(ury, Ascender);
     float minDescent = Math.Min(lly, Descender);
     Ascender = maxAscent * 1000 / (maxAscent - minDescent);
     Descender = minDescent * 1000 / (maxAscent - minDescent);
 }
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:41,代碼來源:DocumentFont.cs

示例6: GetPageSize

 /**
 * Gets the page from a page dictionary
 * @param page the page dictionary
 * @return the page
 */    
 virtual public Rectangle GetPageSize(PdfDictionary page) {
     PdfArray mediaBox = page.GetAsArray(PdfName.MEDIABOX);
     return GetNormalizedRectangle(mediaBox);
 }
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例7: KidNode

 protected virtual void KidNode(PdfDictionary merged, String name) {
     PdfArray kids = merged.GetAsArray(PdfName.KIDS);
     if (kids == null || kids.Size == 0) {
         if (name.Length > 0)
             name = name.Substring(1);
         fields[name] = merged;
     }
     else {
         merged.Remove(PdfName.KIDS);
         for (int k = 0; k < kids.Size; ++k) {
             PdfDictionary dic = new PdfDictionary();
             dic.Merge(merged);
             PdfDictionary newDic = kids.GetAsDict(k);
             PdfString t = newDic.GetAsString(PdfName.T);
             String newName = name;
             if (t != null)
                 newName += "." + t.ToUnicodeString();
             dic.Merge(newDic);
             dic.Remove(PdfName.T);
             KidNode(dic, newName);
         }
     }
 }
開發者ID:,項目名稱:,代碼行數:23,代碼來源:

示例8: RemoveAnnots

 /// <summary>
 /// Removes annotations from a page dictionary </summary>
 /// <param name="page">	a page dictionary </param>
 /// <param name="ocgs">	a set of names of OCG layers </param>
 private void RemoveAnnots(PdfDictionary page, ICollection<string> ocgs)
 {
     PdfArray annots = page.GetAsArray(PdfName.ANNOTS);
     if (annots == null)
     {
         return;
     }
     IList<int?> remove = new List<int?>();
     for (int i = annots.Size; i > 0; )
     {
         PdfDictionary annot = annots.GetAsDict(--i);
         if (IsToBeRemoved(annot.GetAsDict(PdfName.OC), ocgs))
         {
             remove.Add(i);
         }
         else
         {
             RemoveOCGsFromArray(annot.GetAsDict(PdfName.A), PdfName.STATE, ocgs);
         }
     }
     foreach (int i in remove)
     {
         annots.Remove(i);
     }
 }
開發者ID:,項目名稱:,代碼行數:29,代碼來源:

示例9: ExtractLocationsFromRedactAnnots

        /**
         * Extracts locations from the redact annotations contained in the document and applied to the given page.
         */
        private IList<PdfCleanUpLocation> ExtractLocationsFromRedactAnnots(int page, PdfDictionary pageDict) {
            List<PdfCleanUpLocation> locations = new List<PdfCleanUpLocation>();

            if (pageDict.Contains(PdfName.ANNOTS)) {
                PdfArray annotsArray = pageDict.GetAsArray(PdfName.ANNOTS);

                for (int i = 0; i < annotsArray.Size; ++i) {
                    PdfIndirectReference annotIndirRef = annotsArray.GetAsIndirectObject(i);
                    PdfDictionary annotDict = annotsArray.GetAsDict(i);
                    PdfName annotSubtype = annotDict.GetAsName(PdfName.SUBTYPE);

                    if (annotSubtype.Equals(PdfName.REDACT)) {
                        SaveRedactAnnotIndirRef(page, annotIndirRef.ToString());
                        locations.AddRange(ExtractLocationsFromRedactAnnot(page, i, annotDict));
                    }
                }
            }

            return locations;
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:23,代碼來源:PdfCleanUpProcessor.cs

示例10: ExtractLocationsFromRedactAnnot

        /**
         * Extracts locations from the concrete annotation.
         * Note: annotation can consist not only of one area specified by the RECT entry, but also of multiple areas specified
         * by the QuadPoints entry in the annotation dictionary.
         */
        private IList<PdfCleanUpLocation> ExtractLocationsFromRedactAnnot(int page, int annotIndex, PdfDictionary annotDict) {
            IList<PdfCleanUpLocation> locations = new List<PdfCleanUpLocation>();
            List<Rectangle> markedRectangles = new List<Rectangle>();
            PdfArray quadPoints = annotDict.GetAsArray(PdfName.QUADPOINTS);

            if (quadPoints.Size != 0) {
                markedRectangles.AddRange(TranslateQuadPointsToRectangles(quadPoints));
            } else {
                PdfArray annotRect = annotDict.GetAsArray(PdfName.RECT);
                markedRectangles.Add(new Rectangle(annotRect.GetAsNumber(0).FloatValue,
                                                   annotRect.GetAsNumber(1).FloatValue,
                                                   annotRect.GetAsNumber(2).FloatValue,
                                                   annotRect.GetAsNumber(3).FloatValue));
            }

            clippingRects.Add(annotIndex, markedRectangles);

            BaseColor cleanUpColor = null;
            PdfArray ic = annotDict.GetAsArray(PdfName.IC);

            if (ic != null) {
                cleanUpColor = new BaseColor(
                    ic.GetAsNumber(0).FloatValue,
                    ic.GetAsNumber(1).FloatValue,
                    ic.GetAsNumber(2).FloatValue
                );
            }


            PdfStream ro = annotDict.GetAsStream(PdfName.RO);

            if (ro != null) {
                cleanUpColor = null;
            }

            foreach (Rectangle rect in markedRectangles) {
                locations.Add(new PdfCleanUpLocation(page, rect, cleanUpColor));
            }

            return locations;
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:46,代碼來源:PdfCleanUpProcessor.cs

示例11: GetComponentsPerPixel

        /**
         * @param colorSpaceName the name of the color space. If null, a bi-tonal (black and white) color space is assumed.
         * @return the components per pixel for the specified color space
         */
        private static int GetComponentsPerPixel(PdfName colorSpaceName, PdfDictionary colorSpaceDic)
        {
            if (colorSpaceName == null)
                return 1;
            if (colorSpaceName.Equals(PdfName.DEVICEGRAY))
                return 1;
            if (colorSpaceName.Equals(PdfName.DEVICERGB))
                return 3;
            if (colorSpaceName.Equals(PdfName.DEVICECMYK))
                return 4;

            if (colorSpaceDic != null){
                PdfArray colorSpace = colorSpaceDic.GetAsArray(colorSpaceName);
                if (colorSpace != null){
                    if (PdfName.INDEXED.Equals(colorSpace.GetAsName(0))){
                        return 1;
                    }
                }
            }

            throw new ArgumentException("Unexpected color space " + colorSpaceName);
        }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:26,代碼來源:InlineImageUtils.cs

示例12: FillDiffMap

 private void FillDiffMap(PdfDictionary encDic, CMapToUnicode toUnicode) {
     PdfArray diffs = encDic.GetAsArray(PdfName.DIFFERENCES);
     if (diffs != null) {
         diffmap = new IntHashtable();
         int currentNumber = 0;
         for (int k = 0; k < diffs.Size; ++k) {
             PdfObject obj = diffs[k];
             if (obj.IsNumber())
                 currentNumber = ((PdfNumber)obj).IntValue;
             else {
                 int[] c = GlyphList.NameToUnicode(PdfName.DecodeName(((PdfName)obj).ToString()));
                 if (c != null && c.Length > 0) {
                     uni2byte[c[0]] = currentNumber;
                     byte2uni[currentNumber] = c[0];
                     diffmap[c[0]] = currentNumber;
                 }
                 else {
                     if (toUnicode == null) {
                         toUnicode = ProcessToUnicode();
                         if (toUnicode == null) {
                             toUnicode = new CMapToUnicode();
                         }
                     }
                     string unicode = toUnicode.Lookup(new byte[]{(byte) currentNumber}, 0, 1);
                     if ((unicode != null) && (unicode.Length == 1)) {
                         this.uni2byte[unicode[0]] = currentNumber;
                         this.byte2uni[currentNumber] = unicode[0];
                         this.diffmap[unicode[0]] = currentNumber;
                     }
                 }
                 ++currentNumber;
             }
         }
     }
 }
開發者ID:Niladri24dutta,項目名稱:itextsharp,代碼行數:35,代碼來源:DocumentFont.cs

示例13: RemoveOCGsFromArray

 /// <summary>
 /// Gets an array from a dictionary and checks if it contains references to OCGs that need to be removed </summary>
 /// <param name="dict">	the dictionary </param>
 /// <param name="name">	the name of an array entry </param>
 /// <param name="ocgs">	the removal list </param>
 private void RemoveOCGsFromArray(PdfDictionary dict, PdfName name, ICollection<string> ocgs)
 {
     if (dict == null)
     {
         return;
     }
     PdfArray array = dict.GetAsArray(name);
     if (array == null)
     {
         return;
     }
     RemoveOCGsFromArray(array, ocgs);
 }
開發者ID:,項目名稱:,代碼行數:18,代碼來源:

示例14: GetKDict

 internal static PdfDictionary GetKDict(PdfDictionary obj) {
     PdfDictionary k = obj.GetAsDict(PdfName.K);
     if (k != null) {
         if (PdfName.OBJR.Equals(k.GetAsName(PdfName.TYPE))) {
             return k;
         }
     } else {
         PdfArray k1 = obj.GetAsArray(PdfName.K);
         if (k1 == null)
             return null;
         for (int i = 0; i < k1.Size; i++) {
             k = k1.GetAsDict(i);
             if (k != null) {
                 if (PdfName.OBJR.Equals(k.GetAsName(PdfName.TYPE))) {
                     return k;
                 }
             }
         }
     }
     return null;
 }
開發者ID:,項目名稱:,代碼行數:21,代碼來源:

示例15: AddKids

// ---------------------------------------------------------------------------    
    public void AddKids(PdfArray dests, PdfDictionary outline) {
      while (outline != null) {
        dests.Add(outline.GetAsString(PdfName.TITLE));
        dests.Add(outline.GetAsArray(PdfName.DEST));
        AddKids(dests, outline.GetAsDict(PdfName.FIRST));
        outline = outline.GetAsDict(PdfName.NEXT);
      }
    }    
開發者ID:,項目名稱:,代碼行數:9,代碼來源:


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