本文整理匯總了C#中iTextSharp.text.pdf.PdfDictionary.GetDirectObject方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfDictionary.GetDirectObject方法的具體用法?C# PdfDictionary.GetDirectObject怎麽用?C# PdfDictionary.GetDirectObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfDictionary
的用法示例。
在下文中一共展示了PdfDictionary.GetDirectObject方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetDictionaryDetail
/**
* Shows the detail of a dictionary.
* @param dic the dictionary of which you want the detail
* @param depth the depth of the current dictionary (for nested dictionaries)
* @return a String representation of the dictionary
*/
public static String GetDictionaryDetail(PdfDictionary dic, int depth){
StringBuilder builder = new StringBuilder();
builder.Append('(');
IList<PdfName> subDictionaries = new List<PdfName>();
foreach (PdfName key in dic.Keys) {
PdfObject val = dic.GetDirectObject(key);
if (val.IsDictionary())
subDictionaries.Add(key);
builder.Append(key);
builder.Append('=');
builder.Append(val);
builder.Append(", ");
}
builder.Length = builder.Length-2;
builder.Append(')');
foreach (PdfName pdfSubDictionaryName in subDictionaries) {
builder.Append('\n');
for (int i = 0; i < depth+1; i++){
builder.Append('\t');
}
builder.Append("Subdictionary ");
builder.Append(pdfSubDictionaryName);
builder.Append(" = ");
builder.Append(GetDictionaryDetail(dic.GetAsDict(pdfSubDictionaryName), depth+1));
}
return builder.ToString();
}
示例2: InspectChildDictionary
/**
* If the child of a structured element is a dictionary, we inspect the
* child; we may also draw a tag.
*
* @param k
* the child dictionary to inspect
*/
public void InspectChildDictionary(PdfDictionary k, bool inspectAttributes) {
if (k == null)
return;
PdfName s = k.GetAsName(PdfName.S);
if (s != null) {
String tagN = PdfName.DecodeName(s.ToString());
String tag = FixTagName(tagN);
outp.Write("<");
outp.Write(tag);
if (inspectAttributes) {
PdfDictionary a = k.GetAsDict(PdfName.A);
if (a != null) {
Dictionary<PdfName, PdfObject>.KeyCollection keys = a.Keys;
foreach (PdfName key in keys) {
outp.Write(' ');
PdfObject value = a.Get(key);
value = PdfReader.GetPdfObject(value);
outp.Write(XmlName(key));
outp.Write("=\"");
outp.Write(value.ToString());
outp.Write("\"");
}
}
}
outp.Write(">");
PdfDictionary dict = k.GetAsDict(PdfName.PG);
if (dict != null)
ParseTag(tagN, k.GetDirectObject(PdfName.K), dict);
InspectChild(k.GetDirectObject(PdfName.K));
outp.Write("</");
outp.Write(tag);
outp.WriteLine(">");
} else
InspectChild(k.GetDirectObject(PdfName.K));
}
示例3: BranchForm
private PdfArray BranchForm(Dictionary<String, Object> level, PdfIndirectReference parent, String fname) {
PdfArray arr = new PdfArray();
foreach (KeyValuePair<String, Object> entry in level) {
String name = entry.Key;
Object obj = entry.Value;
PdfIndirectReference ind = PdfIndirectReference;
PdfDictionary dic = new PdfDictionary();
if (parent != null)
dic.Put(PdfName.PARENT, parent);
dic.Put(PdfName.T, new PdfString(name, PdfObject.TEXT_UNICODE));
String fname2 = fname + "." + name;
int coidx = calculationOrder.IndexOf(fname2);
if (coidx >= 0)
calculationOrderRefs[coidx] = ind;
if (obj is Dictionary<String, Object>) {
dic.Put(PdfName.KIDS, BranchForm((Dictionary<String, Object>) obj, ind, fname2));
arr.Add(ind);
AddToBody(dic, ind, true);
} else {
List<Object> list = (List<Object>)obj;
dic.MergeDifferent((PdfDictionary) list[0]);
if (list.Count == 3) {
dic.MergeDifferent((PdfDictionary)list[2]);
int page = (int)list[1];
PdfArray annots = importedPages[page - 1].mergedFields;
PdfNumber nn = (PdfNumber)dic.Get(iTextTag);
dic.Remove(iTextTag);
dic.Put(PdfName.TYPE, PdfName.ANNOT);
AdjustTabOrder(annots, ind, nn);
} else {
PdfDictionary field = (PdfDictionary)list[0];
PdfArray kids = new PdfArray();
for (int k = 1; k < list.Count; k += 2) {
int page = (int)list[k];
PdfArray annots = importedPages[page - 1].mergedFields;
PdfDictionary widget = new PdfDictionary();
widget.Merge((PdfDictionary)list[k + 1]);
widget.Put(PdfName.PARENT, ind);
PdfNumber nn = (PdfNumber)widget.Get(iTextTag);
widget.Remove(iTextTag);
if (PdfCopy.IsTextField(field)) {
PdfString v = field.GetAsString(PdfName.V);
PdfObject ap = widget.GetDirectObject(PdfName.AP);
if (v != null && ap != null) {
if (!mergedTextFields.ContainsKey(list)) {
mergedTextFields[list] = v;
} else {
try {
TextField tx = new TextField(this, null, null);
fields[0].DecodeGenericDictionary(widget, tx);
Rectangle box =
PdfReader.GetNormalizedRectangle(widget.GetAsArray(PdfName.RECT));
if (tx.Rotation == 90 || tx.Rotation == 270) {
box = box.Rotate();
}
tx.Box = box;
tx.Text = mergedTextFields[list].ToUnicodeString();
PdfAppearance app = tx.GetAppearance();
((PdfDictionary) ap).Put(PdfName.N, app.IndirectReference);
}
catch (DocumentException ex) {
//do nothing
}
}
}
} else if (PdfCopy.IsCheckButton(field)) {
PdfName v = field.GetAsName(PdfName.V);
PdfName as_ = widget.GetAsName(PdfName.AS);
if (v != null && as_ != null)
widget.Put(PdfName.AS, v);
} else if (PdfCopy.IsRadioButton(field)) {
PdfName v = field.GetAsName(PdfName.V);
PdfName as_ = widget.GetAsName(PdfName.AS);
if (v != null && as_ != null && !as_.Equals(GetOffStateName(widget))) {
if (!mergedRadioButtons.Contains(list)) {
mergedRadioButtons.Add(list);
widget.Put(PdfName.AS, v);
} else {
widget.Put(PdfName.AS, GetOffStateName(widget));
}
}
}
widget.Put(PdfName.TYPE, PdfName.ANNOT);
PdfIndirectReference wref = AddToBody(widget, PdfIndirectReference, true).IndirectReference;
AdjustTabOrder(annots, wref, nn);
kids.Add(wref);
}
dic.Put(PdfName.KIDS, kids);
}
arr.Add(ind);
AddToBody(dic, ind, true);
}
}
return arr;
}