本文整理汇总了C#中PdfObject.SetObjectID方法的典型用法代码示例。如果您正苦于以下问题:C# PdfObject.SetObjectID方法的具体用法?C# PdfObject.SetObjectID怎么用?C# PdfObject.SetObjectID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfObject
的用法示例。
在下文中一共展示了PdfObject.SetObjectID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadObject
/// <summary>
/// Reads PDF object from input stream.
/// </summary>
/// <param name="pdfObject">Either the instance of a derived type or null. If it is null
/// an appropriate object is created.</param>
/// <param name="objectID">The address of the object.</param>
/// <param name="includeReferences">If true, specifies that all indirect objects
/// are included recursively.</param>
/// <param name="fromObjecStream">If true, the objects is parsed from an object stream.</param>
public PdfObject ReadObject(PdfObject pdfObject, PdfObjectID objectID, bool includeReferences, bool fromObjecStream)
{
#if DEBUG_
Debug.WriteLine("ReadObject: " + objectID);
if (objectID.ObjectNumber == 20)
GetType();
#endif
int objectNumber = objectID.ObjectNumber;
int generationNumber = objectID.GenerationNumber;
if (!fromObjecStream)
{
MoveToObject(objectID);
objectNumber = ReadInteger();
generationNumber = ReadInteger();
}
#if DEBUG
// The following assertion sometime failed (see below)
//Debug.Assert(objectID == new PdfObjectID(objectNumber, generationNumber));
if (!fromObjecStream && objectID != new PdfObjectID(objectNumber, generationNumber))
{
// A special kind of bug? Or is this an undocumented PDF feature?
// PDF4NET 2.6 provides a sample called 'Unicode', which produces a file 'unicode.pdf'
// The iref table of this file contains the following entries:
// iref
// 0 148
// 0000000000 65535 f
// 0000000015 00000 n
// 0000000346 00000 n
// ....
// 0000083236 00000 n
// 0000083045 00000 n
// 0000083045 00000 n
// 0000083045 00000 n
// 0000083045 00000 n
// 0000080334 00000 n
// ....
// Object 84, 85, 86, and 87 maps to the same dictionary, but all PDF readers I tested
// ignores this mismatch! The following assertion failed about 50 times with this file.
#if true_
string message = String.Format("xref entry {0} {1} maps to object {2} {3}.",
objectID.ObjectNumber, objectID.GenerationNumber, objectNumber, generationNumber);
Debug.Assert(false, message);
#endif
}
#endif
// Always use object ID from iref table (see above).
objectNumber = objectID.ObjectNumber;
generationNumber = objectID.GenerationNumber;
#if true_
Debug.WriteLine(String.Format("obj: {0} {1}", objectNumber, generationNumber));
#endif
if (!fromObjecStream)
ReadSymbol(Symbol.Obj);
bool checkForStream = false;
Symbol symbol = ScanNextToken();
switch (symbol)
{
case Symbol.BeginArray:
PdfArray array;
if (pdfObject == null)
array = new PdfArray(_document);
else
array = (PdfArray)pdfObject;
//PdfObject.RegisterObject(array, objectID, generation);
pdfObject = ReadArray(array, includeReferences);
pdfObject.SetObjectID(objectNumber, generationNumber);
break;
case Symbol.BeginDictionary:
PdfDictionary dict;
if (pdfObject == null)
dict = new PdfDictionary(_document);
else
dict = (PdfDictionary)pdfObject;
//PdfObject.RegisterObject(dict, objectID, generation);
checkForStream = true;
pdfObject = ReadDictionary(dict, includeReferences);
pdfObject.SetObjectID(objectNumber, generationNumber);
break;
// Acrobat 6 Professional proudly presents: The Null object!
// Even with a one-digit object number an indirect reference «x 0 R» to this object is
// one character larger than the direct use of «null». Probable this is the reason why
// it is true that Acrobat Web Capture 6.0 creates this object, but obviously never
// creates a reference to it!
case Symbol.Null:
pdfObject = new PdfNullObject(_document);
pdfObject.SetObjectID(objectNumber, generationNumber);
if (!fromObjecStream)
ReadSymbol(Symbol.EndObj);
//.........这里部分代码省略.........
示例2: ReadObjectID
//protected Symbol ScanNextToken(out string token, bool testReference)
//{
// Symbol symbol = lexer.ScanNextToken(testReference);
// token = lexer.Token;
// return symbol;
//}
// internal object ReadObject(int position)
// {
// lexer.Position = position;
// return ReadObject(false);
// }
//
// internal virtual object ReadObject(bool directObject)
// {
// throw new InvalidOperationException("PdfParser.ReadObject() base class called");
// }
/// <summary>
/// Reads the object ID and the generation and sets it into the specified object.
/// </summary>
private void ReadObjectID(PdfObject obj)
{
int objectNubmer = ReadInteger();
int generationNumber = ReadInteger();
ReadSymbol(Symbol.Obj);
if (obj != null)
obj.SetObjectID(objectNubmer, generationNumber);
}
示例3: Add
/// <summary>
/// Adds a PdfObject to the table.
/// </summary>
public void Add(PdfObject value)
{
if (value.Owner == null)
value.Document = _document;
else
Debug.Assert(value.Owner == _document);
if (value.ObjectID.IsEmpty)
value.SetObjectID(GetNewObjectNumber(), 0);
if (ObjectTable.ContainsKey(value.ObjectID))
throw new InvalidOperationException("Object already in table.");
ObjectTable.Add(value.ObjectID, value.Reference);
}