本文整理匯總了C#中iTextSharp.text.pdf.IntHashtable.ContainsKey方法的典型用法代碼示例。如果您正苦於以下問題:C# IntHashtable.ContainsKey方法的具體用法?C# IntHashtable.ContainsKey怎麽用?C# IntHashtable.ContainsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.IntHashtable
的用法示例。
在下文中一共展示了IntHashtable.ContainsKey方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FindAllObjects
internal static void FindAllObjects(PdfReader reader, PdfObject obj, IntHashtable hits) {
if (obj == null)
return;
switch (obj.Type) {
case PdfObject.INDIRECT:
PRIndirectReference iref = (PRIndirectReference)obj;
if (reader != iref.Reader)
return;
if (hits.ContainsKey(iref.Number))
return;
hits[iref.Number] = 1;
FindAllObjects(reader, PdfReader.GetPdfObject(obj), hits);
return;
case PdfObject.ARRAY:
PdfArray a = (PdfArray)obj;
for (int k = 0; k < a.Size; ++k) {
FindAllObjects(reader, a[k], hits);
}
return;
case PdfObject.DICTIONARY:
case PdfObject.STREAM:
PdfDictionary dic = (PdfDictionary)obj;
foreach (PdfName name in dic.Keys) {
FindAllObjects(reader, dic.Get(name), hits);
}
return;
}
}
示例2: FillMetrics
private void FillMetrics(byte[] touni, IntHashtable widths, int dw) {
PdfContentParser ps = new PdfContentParser(new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateSource(touni))));
PdfObject ob = null;
bool notFound = true;
int nestLevel = 0;
int maxExc = 50;
while ((notFound || nestLevel > 0)) {
try {
ob = ps.ReadPRObject();
}
catch {
if (--maxExc < 0)
break;
continue;
}
if (ob == null)
break;
if (ob.Type == PdfContentParser.COMMAND_TYPE) {
if (ob.ToString().Equals("begin")) {
notFound = false;
nestLevel++;
}
else if (ob.ToString().Equals("end")) {
nestLevel--;
}
else if (ob.ToString().Equals("beginbfchar")) {
while (true) {
PdfObject nx = ps.ReadPRObject();
if (nx.ToString().Equals("endbfchar"))
break;
String cid = DecodeString((PdfString)nx);
String uni = DecodeString((PdfString)ps.ReadPRObject());
if (uni.Length == 1) {
int cidc = (int)cid[0];
int unic = (int)uni[uni.Length - 1];
int w = dw;
if (widths.ContainsKey(cidc))
w = widths[cidc];
metrics[unic] = new int[]{cidc, w};
}
}
}
else if (ob.ToString().Equals("beginbfrange")) {
while (true) {
PdfObject nx = ps.ReadPRObject();
if (nx.ToString().Equals("endbfrange"))
break;
String cid1 = DecodeString((PdfString)nx);
String cid2 = DecodeString((PdfString)ps.ReadPRObject());
int cid1c = (int)cid1[0];
int cid2c = (int)cid2[0];
PdfObject ob2 = ps.ReadPRObject();
if (ob2.IsString()) {
String uni = DecodeString((PdfString)ob2);
if (uni.Length == 1) {
int unic = (int)uni[uni.Length - 1];
for (; cid1c <= cid2c; cid1c++, unic++) {
int w = dw;
if (widths.ContainsKey(cid1c))
w = widths[cid1c];
metrics[unic] = new int[]{cid1c, w};
}
}
}
else {
PdfArray a = (PdfArray)ob2;
for (int j = 0; j < a.Size; ++j, ++cid1c) {
String uni = DecodeString(a.GetAsString(j));
if (uni.Length == 1) {
int unic = (int)uni[uni.Length - 1];
int w = dw;
if (widths.ContainsKey(cid1c))
w = widths[cid1c];
metrics[unic] = new int[]{cid1c, w};
}
}
}
}
}
}
}
}
示例3: WriteFont
internal override void WriteFont(PdfWriter writer, PdfIndirectReference piRef, Object[] oParams)
{
if (this.writer != writer)
throw new ArgumentException("Type3 font used with the wrong PdfWriter");
if (char2byte.Size != widths3.Size)
throw new DocumentException("Not all the glyphs in the Type3 font are defined");
IntHashtable inv = new IntHashtable();
for (IntHashtable.IntHashtableIterator it = char2byte.GetEntryIterator(); it.HasNext();) {
IntHashtable.IntHashtableEntry entry = it.Next();
inv[entry.Value] = entry.Key;
}
int[] invOrd = inv.ToOrderedKeys();
int firstChar = invOrd[0];
int lastChar = invOrd[invOrd.Length - 1];
int[] widths = new int[lastChar - firstChar + 1];
for (int k = 0; k < widths.Length; ++k) {
if (inv.ContainsKey(k + firstChar))
widths[k] = widths3[inv[k + firstChar]];
}
PdfArray diffs = new PdfArray();
PdfDictionary charprocs = new PdfDictionary();
int last = -1;
for (int k = 0; k < invOrd.Length; ++k) {
int c = invOrd[k];
if (c > last) {
last = c;
diffs.Add(new PdfNumber(last));
}
++last;
int c2 = inv[c];
String s = GlyphList.UnicodeToName(c2);
if (s == null)
s = "a" + c2;
PdfName n = new PdfName(s);
diffs.Add(n);
Type3Glyph glyph = (Type3Glyph)char2glyph[(char)c2];
PdfStream stream = new PdfStream(glyph.ToPdf(null));
stream.FlateCompress();
PdfIndirectReference refp = writer.AddToBody(stream).IndirectReference;
charprocs.Put(n, refp);
}
PdfDictionary font = new PdfDictionary(PdfName.FONT);
font.Put(PdfName.SUBTYPE, PdfName.TYPE3);
if (colorized)
font.Put(PdfName.FONTBBOX, new PdfRectangle(0, 0, 0, 0));
else
font.Put(PdfName.FONTBBOX, new PdfRectangle(llx, lly, urx, ury));
font.Put(PdfName.FONTMATRIX, new PdfArray(new float[]{0.001f, 0, 0, 0.001f, 0, 0}));
font.Put(PdfName.CHARPROCS, writer.AddToBody(charprocs).IndirectReference);
PdfDictionary encoding = new PdfDictionary();
encoding.Put(PdfName.DIFFERENCES, diffs);
font.Put(PdfName.ENCODING, writer.AddToBody(encoding).IndirectReference);
font.Put(PdfName.FIRSTCHAR, new PdfNumber(firstChar));
font.Put(PdfName.LASTCHAR, new PdfNumber(lastChar));
font.Put(PdfName.WIDTHS, writer.AddToBody(new PdfArray(widths)).IndirectReference);
if (pageResources.HasResources())
font.Put(PdfName.RESOURCES, writer.AddToBody(pageResources.Resources).IndirectReference);
writer.AddToBody(font, piRef);
}
示例4: FillMetricsIdentity
private void FillMetricsIdentity(IntHashtable widths, int dw) {
for (int i = 0; i < 65536; i++) {
int w = dw;
if (widths.ContainsKey(i))
w = widths[i];
metrics.Add(i, new int[] { i, w });
}
}
示例5: FillMetrics
private void FillMetrics(byte[] touni, IntHashtable widths, int dw)
{
PdfContentParser ps = new PdfContentParser(new PRTokeniser(touni));
PdfObject ob = null;
PdfObject last = null;
while ((ob = ps.ReadPRObject()) != null) {
if (ob.Type == PdfContentParser.COMMAND_TYPE) {
if (ob.ToString().Equals("beginbfchar")) {
int n = ((PdfNumber)last).IntValue;
for (int k = 0; k < n; ++k) {
String cid = DecodeString((PdfString)ps.ReadPRObject());
String uni = DecodeString((PdfString)ps.ReadPRObject());
if (uni.Length == 1) {
int cidc = (int)cid[0];
int unic = (int)uni[uni.Length - 1];
int w = dw;
if (widths.ContainsKey(cidc))
w = widths[cidc];
metrics[unic] = new int[]{cidc, w};
}
}
}
else if (ob.ToString().Equals("beginbfrange")) {
int n = ((PdfNumber)last).IntValue;
for (int k = 0; k < n; ++k) {
String cid1 = DecodeString((PdfString)ps.ReadPRObject());
String cid2 = DecodeString((PdfString)ps.ReadPRObject());
int cid1c = (int)cid1[0];
int cid2c = (int)cid2[0];
PdfObject ob2 = ps.ReadPRObject();
if (ob2.IsString()) {
String uni = DecodeString((PdfString)ob2);
if (uni.Length == 1) {
int unic = (int)uni[uni.Length - 1];
for (; cid1c <= cid2c; cid1c++, unic++) {
int w = dw;
if (widths.ContainsKey(cid1c))
w = widths[cid1c];
metrics[unic] = new int[]{cid1c, w};
}
}
}
else {
ArrayList ar = ((PdfArray)ob2).ArrayList;
for (int j = 0; j < ar.Count; ++j, ++cid1c) {
String uni = DecodeString((PdfString)ar[j]);
if (uni.Length == 1) {
int unic = (int)uni[uni.Length - 1];
int w = dw;
if (widths.ContainsKey(cid1c))
w = widths[cid1c];
metrics[unic] = new int[]{cid1c, w};
}
}
}
}
}
}
else
last = ob;
}
}
示例6: RecourseFonts
private static void RecourseFonts(PdfDictionary page, IntHashtable hits, List<object[]> fonts, int level, HashSet2<PdfDictionary> visitedResources)
{
++level;
if (level > 50) // in case we have an endless loop
return;
if (page == null)
return;
PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
if (resources == null)
return;
PdfDictionary font = resources.GetAsDict(PdfName.FONT);
if (font != null) {
foreach (PdfName key in font.Keys) {
PdfObject ft = font.Get(key);
if (ft == null || !ft.IsIndirect())
continue;
int hit = ((PRIndirectReference)ft).Number;
if (hits.ContainsKey(hit))
continue;
AddFont((PRIndirectReference)ft, hits, fonts);
}
}
PdfDictionary xobj = resources.GetAsDict(PdfName.XOBJECT);
if(xobj != null){
if (visitedResources.AddAndCheck(xobj)){
foreach (PdfName key in xobj.Keys) {
PdfObject po = xobj.GetDirectObject(key);
if (po is PdfDictionary)
RecourseFonts((PdfDictionary)po, hits, fonts, level, visitedResources);
}
visitedResources.Remove(xobj);
} else
throw new InvalidPdfException(MessageLocalization.GetComposedMessage("illegal.resources.tree"));
}
}
示例7: ReadObjStm
protected internal void ReadObjStm(PRStream stream, IntHashtable map) {
int first = stream.GetAsNumber(PdfName.FIRST).IntValue;
int n = stream.GetAsNumber(PdfName.N).IntValue;
byte[] b = GetStreamBytes(stream, tokens.File);
PRTokeniser saveTokens = tokens;
tokens = new PRTokeniser(b);
try {
int[] address = new int[n];
int[] objNumber = new int[n];
bool ok = true;
for (int k = 0; k < n; ++k) {
ok = tokens.NextToken();
if (!ok)
break;
if (tokens.TokenType != PRTokeniser.TK_NUMBER) {
ok = false;
break;
}
objNumber[k] = tokens.IntValue;
ok = tokens.NextToken();
if (!ok)
break;
if (tokens.TokenType != PRTokeniser.TK_NUMBER) {
ok = false;
break;
}
address[k] = tokens.IntValue + first;
}
if (!ok)
throw new InvalidPdfException("Error reading ObjStm");
for (int k = 0; k < n; ++k) {
if (map.ContainsKey(k)) {
tokens.Seek(address[k]);
PdfObject obj = ReadPRObject();
xrefObj[objNumber[k]] = obj;
}
}
}
finally {
tokens = saveTokens;
}
}