本文整理匯總了C#中iTextSharp.text.pdf.PdfObject.IsDictionary方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfObject.IsDictionary方法的具體用法?C# PdfObject.IsDictionary怎麽用?C# PdfObject.IsDictionary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfObject
的用法示例。
在下文中一共展示了PdfObject.IsDictionary方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SerObject
private void SerObject(PdfObject obj, int level, ByteBuffer bb, Dictionary<RefKey, int> serialized)
{
if (level <= 0)
return;
if (obj == null) {
bb.Append("$Lnull");
return;
}
PdfIndirectReference refe = null;
ByteBuffer savedBb = null;
if (obj.IsIndirect()) {
refe = (PdfIndirectReference)obj;
RefKey key = new RefKey(refe);
if (serialized.ContainsKey(key)) {
bb.Append(serialized[key]);
return;
}
else {
savedBb = bb;
bb = new ByteBuffer();
}
}
obj = PdfReader.GetPdfObject(obj);
if (obj.IsStream()) {
bb.Append("$B");
SerDic((PdfDictionary)obj, level - 1, bb, serialized);
if (level > 0) {
bb.Append(DigestAlgorithms.Digest("MD5", PdfReader.GetStreamBytesRaw((PRStream)obj)));
}
}
else if (obj.IsDictionary()) {
SerDic((PdfDictionary)obj, level - 1, bb,serialized);
}
else if (obj.IsArray()) {
SerArray((PdfArray)obj, level - 1, bb,serialized);
}
else if (obj.IsString()) {
bb.Append("$S").Append(obj.ToString());
}
else if (obj.IsName()) {
bb.Append("$N").Append(obj.ToString());
}
else
bb.Append("$L").Append(obj.ToString());
if (savedBb != null) {
RefKey key = new RefKey(refe);
if (!serialized.ContainsKey(key))
serialized[key] = CalculateHash(bb.Buffer);
savedBb.Append(bb);
}
}
示例2: CompareObjects
public static bool CompareObjects(PdfObject value1, PdfObject value2) {
value2 = GetDirectObject(value2);
if (value2 == null)
return false;
if (value1.Type != value2.Type)
return false;
if (value1.IsBoolean()){
if (value1 == value2)
return true;
if (value2 is PdfBoolean) {
return ((PdfBoolean)value1).BooleanValue == ((PdfBoolean)value2).BooleanValue;
}
return false;
} else if (value1.IsName()) {
return value1.Equals(value2);
} else if (value1.IsNumber()){
if (value1 == value2)
return true;
if (value2 is PdfNumber) {
return ((PdfNumber)value1).DoubleValue == ((PdfNumber)value2).DoubleValue;
}
return false;
} else if (value1.IsNull()){
if (value1 == value2)
return true;
if (value2 is PdfNull)
return true;
return false;
} else if (value1.IsString()){
if (value1 == value2)
return true;
if (value2 is PdfString) {
return ((value2 == null && value1.ToString() == null)
|| value1.ToString() == value2.ToString());
}
return false;
}
if (value1.IsArray()) {
PdfArray array1 = (PdfArray)value1;
PdfArray array2 = (PdfArray)value2;
if (array1.Size != array2.Size)
return false;
for (int i = 0; i < array1.Size; ++i)
if (!CompareObjects(array1[i],array2[i]))
return false;
return true;
}
if (value1.IsDictionary()) {
PdfDictionary first = (PdfDictionary)value1;
PdfDictionary second = (PdfDictionary)value2;
if (first.Size != second.Size)
return false;
foreach (PdfName name in first.hashMap.Keys) {
if (!CompareObjects(first.Get(name),second.Get(name)))
return false;
}
return true;
}
return false;
}
示例3: AddClass
internal void AddClass(PdfObject obj) {
obj = GetDirectObject(obj);
if (obj.IsDictionary()) {
PdfObject curClass = ((PdfDictionary)obj).Get(PdfName.C);
if (curClass == null)
return;
if (curClass.IsArray()) {
PdfArray array = (PdfArray)curClass;
for (int i = 0; i < array.Size; ++i) {
AddClass(array[i]);
}
} else if (curClass.IsName())
AddClass(curClass);
} else if (obj.IsName()) {
PdfName name = (PdfName)obj;
if (sourceClassMap == null) {
obj = GetDirectObject(structTreeRoot.Get(PdfName.CLASSMAP));
if (obj == null || !obj.IsDictionary()) {
return;
}
sourceClassMap = (PdfDictionary)obj;
}
obj = GetDirectObject(sourceClassMap.Get(name));
if (obj == null) {
return;
}
PdfObject put = structureTreeRoot.GetMappedClass(name);
if (put != null) {
if (!CompareObjects(put,obj)) {
throw new BadPdfFormatException(MessageLocalization.GetComposedMessage("conflict.in.classmap",name));
}
} else {
if (obj.IsDictionary())
structureTreeRoot.MapClass(name, GetDirectDict((PdfDictionary)obj));
else if (obj.IsArray()) {
structureTreeRoot.MapClass(name, GetDirectArray((PdfArray)obj));
}
}
}
}
示例4: ConvertNamedDestination
/**
* Converts a remote named destination GoToR with a local named destination
* if there's a corresponding name.
* @param obj an annotation that needs to be screened for links to external named destinations.
* @param names a map with names of local named destinations
* @since iText 5.0
*/
private bool ConvertNamedDestination(PdfObject obj, Dictionary<Object, PdfObject> names) {
obj = GetPdfObject(obj);
int objIdx = lastXrefPartial;
ReleaseLastXrefPartial();
if (obj != null && obj.IsDictionary()) {
PdfObject ob2 = GetPdfObject(((PdfDictionary)obj).Get(PdfName.A));
if (ob2 != null) {
int obj2Idx = lastXrefPartial;
ReleaseLastXrefPartial();
PdfDictionary dic = (PdfDictionary)ob2;
PdfName type = (PdfName)GetPdfObjectRelease(dic.Get(PdfName.S));
if (PdfName.GOTOR.Equals(type)) {
PdfObject ob3 = GetPdfObjectRelease(dic.Get(PdfName.D));
Object name = null;
if (ob3 != null) {
if (ob3.IsName())
name = ob3;
else if (ob3.IsString())
name = ob3.ToString();
PdfArray dest = null;
if (name != null && names.ContainsKey(name))
dest = (PdfArray)names[name];
if (dest != null) {
dic.Remove(PdfName.F);
dic.Remove(PdfName.NEWWINDOW);
dic.Put(PdfName.S, PdfName.GOTO);
SetXrefPartialObject(obj2Idx, ob2);
SetXrefPartialObject(objIdx, obj);
return true;
}
}
}
}
}
return false;
}
示例5: ReplaceNamedDestination
private bool ReplaceNamedDestination(PdfObject obj, Dictionary<Object, PdfObject> names) {
obj = GetPdfObject(obj);
int objIdx = lastXrefPartial;
ReleaseLastXrefPartial();
if (obj != null && obj.IsDictionary()) {
PdfObject ob2 = GetPdfObjectRelease(((PdfDictionary)obj).Get(PdfName.DEST));
Object name = null;
if (ob2 != null) {
if (ob2.IsName())
name = ob2;
else if (ob2.IsString())
name = ob2.ToString();
if (name != null) {
PdfArray dest = null;
if (names.ContainsKey(name) && names[name] is PdfArray)
dest = (PdfArray)names[name];
if (dest != null) {
((PdfDictionary)obj).Put(PdfName.DEST, dest);
SetXrefPartialObject(objIdx, obj);
return true;
}
}
}
else if ((ob2 = GetPdfObject(((PdfDictionary)obj).Get(PdfName.A))) != null) {
int obj2Idx = lastXrefPartial;
ReleaseLastXrefPartial();
PdfDictionary dic = (PdfDictionary)ob2;
PdfName type = (PdfName)GetPdfObjectRelease(dic.Get(PdfName.S));
if (PdfName.GOTO.Equals(type)) {
PdfObject ob3 = GetPdfObjectRelease(dic.Get(PdfName.D));
if (ob3 != null) {
if (ob3.IsName())
name = ob3;
else if (ob3.IsString())
name = ob3.ToString();
}
if (name != null) {
PdfArray dest = null;
if (names.ContainsKey(name) && names[name] is PdfArray)
dest = (PdfArray)names[name];
if (dest != null) {
dic.Put(PdfName.D, dest);
SetXrefPartialObject(obj2Idx, ob2);
SetXrefPartialObject(objIdx, obj);
return true;
}
}
}
}
}
return false;
}
示例6: Propagate
private PdfObject Propagate(PdfObject obj) {
if (obj == null) {
return new PdfNull();
} else if (obj.IsArray()) {
PdfArray a = (PdfArray)obj;
for (int i = 0; i < a.Size; i++) {
a.Set(i, Propagate(a.GetPdfObject(i)));
}
return a;
} else if (obj.IsDictionary() || obj.IsStream()) {
PdfDictionary d = (PdfDictionary)obj;
List<PdfName> keys = new List<PdfName>(d.Keys);
foreach (PdfName key in keys) {
d.Put(key, Propagate(d.Get(key)));
}
return d;
} else if (obj.IsIndirect()) {
obj = PdfReader.GetPdfObject(obj);
return AddToBody(Propagate(obj)).IndirectReference;
} else
return obj;
}
示例7: GetNameArray
private static PdfArray GetNameArray(PdfObject obj) {
if (obj == null)
return null;
obj = GetPdfObjectRelease(obj);
if (obj == null)
return null;
if (obj.IsArray())
return (PdfArray)obj;
else if (obj.IsDictionary()) {
PdfObject arr2 = GetPdfObjectRelease(((PdfDictionary)obj).Get(PdfName.D));
if (arr2 != null && arr2.IsArray())
return (PdfArray)arr2;
}
return null;
}
示例8: UpdateReferences
private void UpdateReferences(PdfObject obj) {
if (obj.IsDictionary() || obj.IsStream()) {
PdfDictionary dictionary = (PdfDictionary)obj;
PdfDictionary newDictionary = new PdfDictionary();
foreach (PdfName key in dictionary.Keys) {
PdfObject o = dictionary.Get(key);
if (o.IsIndirect()) {
PdfReader reader = ((PRIndirectReference)o).Reader;
Dictionary<RefKey,IndirectReferences> indirects = indirectMap[reader];
IndirectReferences indRef = null;
if (indirects.TryGetValue(new RefKey((PRIndirectReference)o), out indRef)) {
newDictionary.Put(key, indRef.Ref);
}
} else {
UpdateReferences(o);
}
}
foreach (PdfName key in newDictionary.Keys) {
dictionary.Put(key, newDictionary.Get(key));
}
} else if (obj.IsArray()) {
PdfArray array = (PdfArray)obj;
for (int i = 0; i < array.Size; i++) {
PdfObject o = array[i];
if (o.IsIndirect()) {
PdfReader reader = ((PRIndirectReference)o).Reader;
Dictionary<RefKey,IndirectReferences> indirects = indirectMap[reader];
IndirectReferences indRef = null;
if (indirects.TryGetValue(new RefKey((PRIndirectReference)o), out indRef)) {
array[i] = indRef.Ref;
}
} else {
UpdateReferences(o);
}
}
}
}
示例9: AddToBody
public new PdfIndirectObject AddToBody(PdfObject objecta, PdfIndirectReference refa, bool formBranching) {
if (formBranching) {
UpdateReferences(objecta);
}
PdfIndirectObject indObj;
if ((tagged || mergeFields) && indirectObjects != null && (objecta.IsArray() || objecta.IsDictionary() || objecta.IsStream())) {
RefKey key = new RefKey(refa);
PdfIndirectObject obj;
if (!indirectObjects.TryGetValue(key, out obj)) {
obj = new PdfIndirectObject(refa, objecta, this);
indirectObjects[key] = obj;
}
indObj = obj;
} else {
indObj = base.AddToBody(objecta, refa);
}
if (mergeFields && objecta.IsDictionary()) {
PdfNumber annotId = ((PdfDictionary)objecta).GetAsNumber(PdfCopy.annotId);
if (annotId != null) {
if (formBranching) {
mergedMap[annotId.IntValue] = indObj;
mergedSet.Add(indObj);
} else {
unmergedMap[annotId.IntValue] = indObj;
unmergedSet.Add(indObj);
}
}
}
return indObj;
}
示例10: UpdateAnnotationReferences
private void UpdateAnnotationReferences(PdfObject obj) {
if (obj.IsArray()) {
PdfArray array = (PdfArray)obj;
for (int i = 0; i < array.Size; i++) {
PdfObject o = array[i];
if (o is PdfIndirectReference) {
foreach (PdfIndirectObject entry in unmergedSet) {
if (entry.IndirectReference.ToString().Equals(o.ToString())) {
if (entry.objecti.IsDictionary()) {
PdfNumber annotId = ((PdfDictionary)entry.objecti).GetAsNumber(PdfCopy.annotId);
if (annotId != null) {
PdfIndirectObject merged = null;
if (mergedMap.TryGetValue(annotId.IntValue, out merged)) {
array[i] = merged.IndirectReference;
}
}
}
}
}
} else {
UpdateAnnotationReferences(o);
}
}
} else if (obj.IsDictionary() || obj.IsStream()) {
PdfDictionary dictionary = (PdfDictionary)obj;
PdfDictionary newDictionary = new PdfDictionary();
foreach (PdfName key in dictionary.Keys) {
PdfObject o = dictionary.Get(key);
if (o is PdfIndirectReference) {
foreach (PdfIndirectObject entry in unmergedSet) {
if (entry.IndirectReference.ToString().Equals(o.ToString())) {
if (entry.objecti.IsDictionary()) {
PdfNumber annotId = ((PdfDictionary)entry.objecti).GetAsNumber(PdfCopy.annotId);
if (annotId != null) {
PdfIndirectObject merged;
if (mergedMap.TryGetValue(annotId.IntValue, out merged)) {
newDictionary.Put(key, merged.IndirectReference);
}
}
}
}
}
} else {
UpdateAnnotationReferences(o);
}
}
foreach (PdfName key in newDictionary.Keys) {
dictionary.Put(key, newDictionary.Get(key));
}
}
}
示例11: Propagate
private PdfObject Propagate(PdfObject obj) {
if (obj == null) {
return new PdfNull();
}
if (obj.IsArray()) {
PdfArray a = (PdfArray)obj;
for (int i = 0; i < a.Size; i++) {
a[i] = Propagate(a[i]);
}
return a;
}
if (obj.IsDictionary() || obj.IsStream()) {
PdfDictionary d = (PdfDictionary)obj;
PdfDictionary newD = new PdfDictionary();
foreach (PdfName key in d.Keys) {
newD.Put(key, Propagate(d.Get(key)));
}
return newD;
}
if (obj.IsIndirect()) {
obj = PdfReader.GetPdfObject(obj);
return AddToBody(Propagate(obj)).IndirectReference;
}
return obj;
}
示例12: SerObject
private void SerObject(PdfObject obj, int level, ByteBuffer bb) {
if (level <= 0)
return;
if (obj == null) {
bb.Append("$Lnull");
return;
}
if (obj.IsIndirect()) {
if (serialized.Contains(obj))
return;
else
serialized.Add(obj);
}
obj = PdfReader.GetPdfObject(obj);
if (obj.IsStream()) {
bb.Append("$B");
SerDic((PdfDictionary)obj, level - 1, bb);
if (level > 0) {
bb.Append(DigestAlgorithms.Digest("MD5", PdfReader.GetStreamBytesRaw((PRStream)obj)));
}
}
else if (obj.IsDictionary()) {
SerDic((PdfDictionary)obj, level - 1, bb);
}
else if (obj.IsArray()) {
SerArray((PdfArray)obj, level - 1, bb);
}
else if (obj.IsString()) {
bb.Append("$S").Append(obj.ToString());
}
else if (obj.IsName()) {
bb.Append("$N").Append(obj.ToString());
}
else
bb.Append("$L").Append(obj.ToString());
}
示例13: GetPropertiesDictionary
private PdfDictionary GetPropertiesDictionary(PdfObject operand1, ResourceDictionary resources){
if (operand1.IsDictionary())
return (PdfDictionary)operand1;
PdfName dictionaryName = ((PdfName)operand1);
return resources.GetAsDict(dictionaryName);
}
示例14: SerObject
private void SerObject(PdfObject obj, int level, ByteBuffer bb)
{
if (level <= 0)
return;
if (obj == null) {
bb.Append("$Lnull");
return;
}
obj = PdfReader.GetPdfObject(obj);
if (obj.IsStream()) {
bb.Append("$B");
SerDic((PdfDictionary)obj, level - 1, bb);
if (level > 0) {
bb.Append(PdfEncryption.DigestComputeHash("MD5", PdfReader.GetStreamBytesRaw((PRStream)obj)));
}
}
else if (obj.IsDictionary()) {
SerDic((PdfDictionary)obj, level - 1, bb);
}
else if (obj.IsArray()) {
SerArray((PdfArray)obj, level - 1, bb);
}
else if (obj.IsString()) {
bb.Append("$S").Append(obj.ToString());
}
else if (obj.IsName()) {
bb.Append("$N").Append(obj.ToString());
}
else
bb.Append("$L").Append(obj.ToString());
}
示例15: DecodePredictor
/**
* @param in
* @param dicPar
* @return a byte array
*/
public static byte[] DecodePredictor(byte[] inp, PdfObject dicPar) {
if (dicPar == null || !dicPar.IsDictionary())
return inp;
PdfDictionary dic = (PdfDictionary)dicPar;
PdfObject obj = GetPdfObject(dic.Get(PdfName.PREDICTOR));
if (obj == null || !obj.IsNumber())
return inp;
int predictor = ((PdfNumber)obj).IntValue;
if (predictor < 10 && predictor != 2)
return inp;
int width = 1;
obj = GetPdfObject(dic.Get(PdfName.COLUMNS));
if (obj != null && obj.IsNumber())
width = ((PdfNumber)obj).IntValue;
int colors = 1;
obj = GetPdfObject(dic.Get(PdfName.COLORS));
if (obj != null && obj.IsNumber())
colors = ((PdfNumber)obj).IntValue;
int bpc = 8;
obj = GetPdfObject(dic.Get(PdfName.BITSPERCOMPONENT));
if (obj != null && obj.IsNumber())
bpc = ((PdfNumber)obj).IntValue;
MemoryStream dataStream = new MemoryStream(inp);
MemoryStream fout = new MemoryStream(inp.Length);
int bytesPerPixel = colors * bpc / 8;
int bytesPerRow = (colors*width*bpc + 7)/8;
byte[] curr = new byte[bytesPerRow];
byte[] prior = new byte[bytesPerRow];
if (predictor == 2) {
if (bpc == 8) {
int numRows = inp.Length/bytesPerRow;
for (int row = 0; row < numRows; row++) {
int rowStart = row*bytesPerRow;
for (int col = 0 + bytesPerPixel; col < bytesPerRow; col++) {
inp[rowStart + col] = (byte) (inp[rowStart + col] + inp[rowStart + col - bytesPerPixel]);
}
}
}
return inp;
}
// Decode the (sub)image row-by-row
while (true) {
// Read the filter type byte and a row of data
int filter = 0;
try {
filter = dataStream.ReadByte();
if (filter < 0) {
return fout.ToArray();
}
int tot = 0;
while (tot < bytesPerRow) {
int n = dataStream.Read(curr, tot, bytesPerRow - tot);
if (n <= 0)
return fout.ToArray();
tot += n;
}
} catch {
return fout.ToArray();
}
switch (filter) {
case 0: //PNG_FILTER_NONE
break;
case 1: //PNG_FILTER_SUB
for (int i = bytesPerPixel; i < bytesPerRow; i++) {
curr[i] += curr[i - bytesPerPixel];
}
break;
case 2: //PNG_FILTER_UP
for (int i = 0; i < bytesPerRow; i++) {
curr[i] += prior[i];
}
break;
case 3: //PNG_FILTER_AVERAGE
for (int i = 0; i < bytesPerPixel; i++) {
curr[i] += (byte)(prior[i] / 2);
}
for (int i = bytesPerPixel; i < bytesPerRow; i++) {
curr[i] += (byte)(((curr[i - bytesPerPixel] & 0xff) + (prior[i] & 0xff))/2);
}
break;
case 4: //PNG_FILTER_PAETH
for (int i = 0; i < bytesPerPixel; i++) {
curr[i] += prior[i];
}
for (int i = bytesPerPixel; i < bytesPerRow; i++) {
int a = curr[i - bytesPerPixel] & 0xff;
int b = prior[i] & 0xff;
int c = prior[i - bytesPerPixel] & 0xff;
int p = a + b - c;
int pa = Math.Abs(p - a);
//.........這裏部分代碼省略.........