本文整理匯總了C#中iTextSharp.text.pdf.PdfDictionary.Get方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfDictionary.Get方法的具體用法?C# PdfDictionary.Get怎麽用?C# PdfDictionary.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfDictionary
的用法示例。
在下文中一共展示了PdfDictionary.Get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CopyPageMarks
private ReturnType CopyPageMarks(PdfDictionary parentTree, PdfNumber arrayNumber, int newArrayNumber) {
PdfArray pages = (PdfArray)GetDirectObject(parentTree.Get(PdfName.NUMS));
if (pages == null) {
PdfArray kids = (PdfArray)GetDirectObject(parentTree.Get(PdfName.KIDS));
if (kids == null)
return ReturnType.NOTFOUND;
int cur = kids.Size/2;
int begin = 0;
while (true) {
PdfDictionary kidTree = (PdfDictionary)GetDirectObject(kids[cur + begin]);
switch (CopyPageMarks(kidTree,arrayNumber,newArrayNumber)) {
case ReturnType.FOUND:
return ReturnType.FOUND;
case ReturnType.ABOVE:
begin += cur;
cur /= 2;
if (cur == 0)
cur = 1;
if (cur + begin == kids.Size)
return ReturnType.ABOVE;
break;
case ReturnType.BELOW:
if (cur + begin == 0)
return ReturnType.BELOW;
if (cur == 0)
return ReturnType.NOTFOUND;
cur /= 2;
break;
default:
return ReturnType.NOTFOUND;
}
}
} else {
if (pages.Size == 0)
return ReturnType.NOTFOUND;
return FindAndCopyMarks(pages, arrayNumber.IntValue, newArrayNumber);
}
}
示例2: SetReader
protected internal void SetReader(PdfReader reader){
this.reader = reader;
PdfObject obj = reader.Catalog.Get(PdfName.STRUCTTREEROOT);
obj = GetDirectObject(obj);
if ((obj == null) || (!obj.IsDictionary()))
throw new BadPdfFormatException(MessageLocalization.GetComposedMessage("no.structtreeroot.found"));
structTreeRoot = (PdfDictionary)obj;
obj = PdfStructTreeController.GetDirectObject(structTreeRoot.Get(PdfName.PARENTTREE));
if (!obj.IsDictionary())
throw new BadPdfFormatException(MessageLocalization.GetComposedMessage("the.document.does.not.contain.parenttree"));
parentTree = (PdfDictionary)obj;
sourceRoleMap = null;
sourceClassMap = null;
}
示例3: SetOriginalResources
internal void SetOriginalResources(PdfDictionary resources, int[] newNamePtr) {
if (newNamePtr != null)
namePtr = newNamePtr;
forbiddenNames = new Dictionary<PdfName,object>();
usedNames = new Dictionary<PdfName,PdfName>();
if (resources == null)
return;
originalResources = new PdfDictionary();
originalResources.Merge(resources);
foreach (PdfName key in resources.Keys) {
PdfObject sub = PdfReader.GetPdfObject(resources.Get(key));
if (sub != null && sub.IsDictionary()) {
PdfDictionary dic = (PdfDictionary)sub;
foreach (PdfName name in dic.Keys) {
forbiddenNames[name] = null;
}
PdfDictionary dic2 = new PdfDictionary();
dic2.Merge(dic);
originalResources.Put(key, dic2);
}
}
}
示例4: BookmarkDepth
private static IList<Dictionary<String, Object>> BookmarkDepth(PdfReader reader, PdfDictionary outline, IntHashtable pages, bool processCurrentOutlineOnly) {
List<Dictionary<String, Object>> list = new List<Dictionary<String, Object>>();
while (outline != null) {
Dictionary<String, Object> map = new Dictionary<string,object>();
PdfString title = (PdfString)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.TITLE));
map["Title"] = title.ToUnicodeString();
PdfArray color = (PdfArray)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.C));
if (color != null && color.Size == 3) {
ByteBuffer outp = new ByteBuffer();
outp.Append(color.GetAsNumber(0).FloatValue).Append(' ');
outp.Append(color.GetAsNumber(1).FloatValue).Append(' ');
outp.Append(color.GetAsNumber(2).FloatValue);
map["Color"] = PdfEncodings.ConvertToString(outp.ToByteArray(), null);
}
PdfNumber style = (PdfNumber)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.F));
if (style != null) {
int f = style.IntValue;
String s = "";
if ((f & 1) != 0)
s += "italic ";
if ((f & 2) != 0)
s += "bold ";
s = s.Trim();
if (s.Length != 0)
map["Style"] = s;
}
PdfNumber count = (PdfNumber)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.COUNT));
if (count != null && count.IntValue < 0)
map["Open"] = "false";
try {
PdfObject dest = PdfReader.GetPdfObjectRelease(outline.Get(PdfName.DEST));
if (dest != null) {
MapGotoBookmark(map, dest, pages); //changed by ujihara 2004-06-13
}
else {
PdfDictionary action = (PdfDictionary)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.A));
if (action != null) {
if (PdfName.GOTO.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
dest = PdfReader.GetPdfObjectRelease(action.Get(PdfName.D));
if (dest != null) {
MapGotoBookmark(map, dest, pages);
}
}
else if (PdfName.URI.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
map["Action"] = "URI";
map["URI"] = ((PdfString)PdfReader.GetPdfObjectRelease(action.Get(PdfName.URI))).ToUnicodeString();
}
else if (PdfName.JAVASCRIPT.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
map["Action"] = "JS";
map["Code"] = PdfReader.GetPdfObjectRelease(action.Get(PdfName.JS)).ToString();
}
else if (PdfName.GOTOR.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
dest = PdfReader.GetPdfObjectRelease(action.Get(PdfName.D));
if (dest != null) {
if (dest.IsString())
map["Named"] = dest.ToString();
else if (dest.IsName())
map["NamedN"] = PdfName.DecodeName(dest.ToString());
else if (dest.IsArray()) {
PdfArray arr = (PdfArray)dest;
StringBuilder s = new StringBuilder();
s.Append(arr[0].ToString());
s.Append(' ').Append(arr[1].ToString());
for (int k = 2; k < arr.Size; ++k)
s.Append(' ').Append(arr[k].ToString());
map["Page"] = s.ToString();
}
}
map["Action"] = "GoToR";
PdfObject file = PdfReader.GetPdfObjectRelease(action.Get(PdfName.F));
if (file != null) {
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
else if (file.IsDictionary()) {
file = PdfReader.GetPdfObject(((PdfDictionary)file).Get(PdfName.F));
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
}
}
PdfObject newWindow = PdfReader.GetPdfObjectRelease(action.Get(PdfName.NEWWINDOW));
if (newWindow != null)
map["NewWindow"] = newWindow.ToString();
}
else if (PdfName.LAUNCH.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
map["Action"] = "Launch";
PdfObject file = PdfReader.GetPdfObjectRelease(action.Get(PdfName.F));
if (file == null)
file = PdfReader.GetPdfObjectRelease(action.Get(PdfName.WIN));
if (file != null) {
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
else if (file.IsDictionary()) {
file = PdfReader.GetPdfObjectRelease(((PdfDictionary)file).Get(PdfName.F));
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
}
}
}
}
}
//.........這裏部分代碼省略.........
示例5: BranchForm
protected 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);
}
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];
PdfDictionary pageDic = pageDics[page - 1];
PdfArray annots = pageDic.GetAsArray(PdfName.ANNOTS);
if (annots == null) {
annots = new PdfArray();
pageDic.Put(PdfName.ANNOTS, annots);
}
PdfNumber nn = (PdfNumber)dic.Get(iTextTag);
dic.Remove(iTextTag);
AdjustTabOrder(annots, ind, nn);
}
else {
PdfArray kids = new PdfArray();
for (int k = 1; k < list.Count; k += 2) {
int page = (int)list[k];
PdfDictionary pageDic = pageDics[page - 1];
PdfArray annots = pageDic.GetAsArray(PdfName.ANNOTS);
if (annots == null) {
annots = new PdfArray();
pageDic.Put(PdfName.ANNOTS, annots);
}
PdfDictionary widget = new PdfDictionary();
widget.Merge((PdfDictionary)list[k + 1]);
widget.Put(PdfName.PARENT, ind);
PdfNumber nn = (PdfNumber)widget.Get(iTextTag);
widget.Remove(iTextTag);
PdfIndirectReference wref = AddToBody(widget).IndirectReference;
AdjustTabOrder(annots, wref, nn);
kids.Add(wref);
Propagate(widget, null, false);
}
dic.Put(PdfName.KIDS, kids);
}
arr.Add(ind);
AddToBody(dic, ind);
Propagate(dic, null, false);
}
}
return arr;
}
示例6: Close
/**
* This is the last method to be called when using external signatures. The general sequence is:
* preClose(), getDocumentBytes() and close().
* <p>
* <CODE>update</CODE> is a <CODE>PdfDictionary</CODE> that must have exactly the
* same keys as the ones provided in {@link #preClose(HashMap)}.
* @param update a <CODE>PdfDictionary</CODE> with the key/value that will fill the holes defined
* in {@link #preClose(HashMap)}
* @throws DocumentException on error
* @throws IOException on error
*/
public void Close(PdfDictionary update) {
try {
if (!preClosed)
throw new DocumentException(MessageLocalization.GetComposedMessage("preclose.must.be.called.first"));
ByteBuffer bf = new ByteBuffer();
foreach (PdfName key in update.Keys) {
PdfObject obj = update.Get(key);
PdfLiteral lit = exclusionLocations[key];
if (lit == null)
throw new ArgumentException(MessageLocalization.GetComposedMessage("the.key.1.didn.t.reserve.space.in.preclose", key.ToString()));
bf.Reset();
obj.ToPdf(null, bf);
if (bf.Size > lit.PosLength)
throw new ArgumentException(MessageLocalization.GetComposedMessage("the.key.1.is.too.big.is.2.reserved.3", key.ToString(), bf.Size, lit.PosLength));
if (tempFile == null)
Array.Copy(bf.Buffer, 0, bout, lit.Position, bf.Size);
else {
raf.Seek(lit.Position, SeekOrigin.Begin);
raf.Write(bf.Buffer, 0, bf.Size);
}
}
if (update.Size != exclusionLocations.Count)
throw new ArgumentException(MessageLocalization.GetComposedMessage("the.update.dictionary.has.less.keys.than.required"));
if (tempFile == null) {
originalout.Write(bout, 0, boutLen);
}
else {
if (originalout != null) {
raf.Seek(0, SeekOrigin.Begin);
long length = raf.Length;
byte[] buf = new byte[8192];
while (length > 0) {
int r = raf.Read(buf, 0, (int)Math.Min((long)buf.Length, length));
if (r < 0)
throw new EndOfStreamException(MessageLocalization.GetComposedMessage("unexpected.eof"));
originalout.Write(buf, 0, r);
length -= r;
}
}
}
}
finally {
writer.reader.Close();
if (tempFile != null) {
try{raf.Close();}catch{}
if (originalout != null)
try{File.Delete(tempFile);}catch{}
}
if (originalout != null)
try{originalout.Close();}catch{}
}
}
示例7: Init
private void Init(PdfDictionary parent, PdfName structureType) {
PdfObject kido = parent.Get(PdfName.K);
PdfArray kids = null;
if (kido != null && !kido.IsArray())
throw new ArgumentException(MessageLocalization.GetComposedMessage("the.parent.has.already.another.function"));
if (kido == null) {
kids = new PdfArray();
parent.Put(PdfName.K, kids);
}
else
kids = (PdfArray)kido;
kids.Add(this);
Put(PdfName.S, structureType);
reference = top.Writer.PdfIndirectReference;
}
示例8: CopyDictionary
/**
* Translate a PRDictionary to a PdfDictionary. Also translate all of the
* objects contained in it.
*/
protected PdfDictionary CopyDictionary(PdfDictionary inp)
{
PdfDictionary outp = new PdfDictionary();
PdfObject type = PdfReader.GetPdfObjectRelease(inp.Get(PdfName.TYPE));
foreach (PdfName key in inp.Keys) {
PdfObject value = inp.Get(key);
if (type != null && PdfName.PAGE.Equals(type)) {
if (!key.Equals(PdfName.B) && !key.Equals(PdfName.PARENT))
outp.Put(key, CopyObject(value));
}
else
outp.Put(key, CopyObject(value));
}
return outp;
}
示例9: IsValid
/**
* Closes the AcroForm.
*/
virtual public bool IsValid() {
if (documentFields.Size == 0) return false;
Put(PdfName.FIELDS, documentFields);
if (sigFlags != 0)
Put(PdfName.SIGFLAGS, new PdfNumber(sigFlags));
if (calculationOrder.Size > 0)
Put(PdfName.CO, calculationOrder);
if (fieldTemplates.Count == 0) return true;
PdfDictionary dic = new PdfDictionary();
foreach (PdfTemplate template in fieldTemplates.Keys) {
PdfFormField.MergeResources(dic, (PdfDictionary)template.Resources);
}
Put(PdfName.DR, dic);
Put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g "));
PdfDictionary fonts = (PdfDictionary)dic.Get(PdfName.FONT);
if (fonts != null) {
writer.EliminateFontSubset(fonts);
}
return true;
}
示例10: MergeResources
internal static void MergeResources(PdfDictionary result, PdfDictionary source, PdfStamperImp writer) {
PdfDictionary dic = null;
PdfDictionary res = null;
PdfName target = null;
for (int k = 0; k < mergeTarget.Length; ++k) {
target = mergeTarget[k];
PdfDictionary pdfDict = source.GetAsDict(target);
if ((dic = pdfDict) != null) {
if ((res = (PdfDictionary)PdfReader.GetPdfObject(result.Get(target), result)) == null) {
res = new PdfDictionary();
}
res.MergeDifferent(dic);
result.Put(target, res);
if (writer != null)
writer.MarkUsed(res);
}
}
}
示例11: IterateItems
private static void IterateItems(PdfDictionary dic, Hashtable items) {
PdfArray nn = (PdfArray)PdfReader.GetPdfObjectRelease(dic.Get(PdfName.NAMES));
if (nn != null) {
for (int k = 0; k < nn.Size; ++k) {
PdfString s = (PdfString)PdfReader.GetPdfObjectRelease(nn[k++]);
items[PdfEncodings.ConvertToString(s.GetBytes(), null)] = nn[k];
}
}
else if ((nn = (PdfArray)PdfReader.GetPdfObjectRelease(dic.Get(PdfName.KIDS))) != null) {
for (int k = 0; k < nn.Size; ++k) {
PdfDictionary kid = (PdfDictionary)PdfReader.GetPdfObjectRelease(nn[k]);
IterateItems(kid, items);
}
}
}
示例12: ProcessType0
private void ProcessType0(PdfDictionary font) {
PdfObject toUniObject = PdfReader.GetPdfObjectRelease(font.Get(PdfName.TOUNICODE));
PdfArray df = (PdfArray)PdfReader.GetPdfObjectRelease(font.Get(PdfName.DESCENDANTFONTS));
PdfDictionary cidft = (PdfDictionary)PdfReader.GetPdfObjectRelease(df[0]);
PdfNumber dwo = (PdfNumber)PdfReader.GetPdfObjectRelease(cidft.Get(PdfName.DW));
int dw = 1000;
if (dwo != null)
dw = dwo.IntValue;
IntHashtable widths = ReadWidths((PdfArray)PdfReader.GetPdfObjectRelease(cidft.Get(PdfName.W)));
PdfDictionary fontDesc = (PdfDictionary)PdfReader.GetPdfObjectRelease(cidft.Get(PdfName.FONTDESCRIPTOR));
FillFontDesc(fontDesc);
if (toUniObject != null){
FillMetrics(PdfReader.GetStreamBytes((PRStream)toUniObject), widths, dw);
}
}
示例13: PushPageAttributes
private void PushPageAttributes(PdfDictionary nodePages) {
PdfDictionary dic = new PdfDictionary();
if (pageInh.Count != 0) {
dic.Merge(pageInh[pageInh.Count - 1]);
}
for (int k = 0; k < pageInhCandidates.Length; ++k) {
PdfObject obj = nodePages.Get(pageInhCandidates[k]);
if (obj != null)
dic.Put(pageInhCandidates[k], obj);
}
pageInh.Add(dic);
}
示例14: DuplicatePdfDictionary
protected internal static PdfDictionary DuplicatePdfDictionary(PdfDictionary original, PdfDictionary copy, PdfReader newReader) {
if (copy == null)
copy = new PdfDictionary();
foreach (PdfName key in original.Keys) {
copy.Put(key, DuplicatePdfObject(original.Get(key), newReader));
}
return copy;
}
示例15: AddKid
virtual protected void AddKid(PdfDictionary parent, PdfObject kid){
PdfObject kidObj = parent.Get(PdfName.K);
PdfArray kids;
if (kidObj is PdfArray){
kids = (PdfArray)kidObj;
} else {
kids = new PdfArray();
if (kidObj != null)
kids.Add(kidObj);
}
kids.Add(kid);
parent.Put(PdfName.K, kids);
}