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


C# PdfDictionary.GetAsString方法代碼示例

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


在下文中一共展示了PdfDictionary.GetAsString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: IsToBeRemoved

 /// <summary>
 /// Checks if an OCG dictionary is on the list for removal. </summary>
 /// <param name="ocg">	a dictionary </param>
 /// <param name="names">	the removal list
 /// @return	true if the dictionary should be removed </param>
 private bool IsToBeRemoved(PdfDictionary ocg, ICollection<string> names)
 {
     if (ocg == null)
     {
         return false;
     }
     PdfString n = ocg.GetAsString(PdfName.NAME);
     if (n == null)
     {
         return false;
     }
     return names.Contains(n.ToString());
 }
開發者ID:,項目名稱:,代碼行數:18,代碼來源:

示例3: 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,代碼來源:

示例4: RenameField

 private String RenameField(Object obj, Dictionary<String, Object> map, PdfDictionary merged)
 {
     String fieldN = null;
     if (obj != null) {
         PdfString fieldName = merged.GetAsString(PdfName.T);
         if (fieldName != null) {
             fieldN = fieldName.ToUnicodeString();
         }
     }
     if (fieldN != null) {
         for (int i = 1; i < int.MaxValue; i++) {
             String tmpFieldName = String.Format("{0}_{1}", fieldN, i);
             if (!map.ContainsKey(tmpFieldName)) {
                 fieldN = tmpFieldName;
                 break;
             }
         }
         merged.Put(PdfName.T, new PdfString(fieldN));
     }
     return fieldN;
 }
開發者ID:htlp,項目名稱:itextsharp,代碼行數:21,代碼來源:PdfCopy.cs


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