本文整理汇总了C#中PdfDictionary类的典型用法代码示例。如果您正苦于以下问题:C# PdfDictionary类的具体用法?C# PdfDictionary怎么用?C# PdfDictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PdfDictionary类属于命名空间,在下文中一共展示了PdfDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageRenderInfo
private ImageRenderInfo(GraphicsState gs, InlineImageInfo inlineImageInfo, PdfDictionary colorSpaceDictionary)
{
this.gs = gs;
this.refi = null;
this.inlineImageInfo = inlineImageInfo;
this.colorSpaceDictionary = colorSpaceDictionary;
}
示例2: PdfStream
private PdfStream(PdfDictionary dictionary, PdfData data)
: base(PdfObjectType.Stream)
{
IsContainer = true;
StreamDictionary = dictionary;
Data = data;
//IPdfObject filter = StreamDictionary["Filter"];
//if (filter.Text == "FlateDecode")
//{
// ZInputStream zin = new ZInputStream(new MemoryStream(Data));
// //zin.
// int r;
// IList<char> output = new List<char>(data.Length*10);
// while ((r = zin.Read()) != -1)
// {
// output.Add((char)r);
// }
// char[] decompressed = output.ToArray();
// String test = new String(decompressed);
// zin.Close();
//}
//else if (filter.Text == "DCTDecode")
//{
// // JPEG image
//}
//else
// throw new NotImplementedException("Implement Filter");
}
示例3: SignaturePermissions
/**
* Creates an object that can inform you about the type of signature
* in a signature dictionary as well as some of the permissions
* defined by the signature.
*/
public SignaturePermissions(PdfDictionary sigDict, SignaturePermissions previous)
{
if (previous != null) {
annotationsAllowed &= previous.AnnotationsAllowed;
fillInAllowed &= previous.FillInAllowed;
fieldLocks.AddRange(previous.FieldLocks);
}
PdfArray reference = sigDict.GetAsArray(PdfName.REFERENCE);
if (reference != null) {
for (int i = 0; i < reference.Size; i++) {
PdfDictionary dict = reference.GetAsDict(i);
PdfDictionary parameters = dict.GetAsDict(PdfName.TRANSFORMPARAMS);
if (PdfName.DOCMDP.Equals(dict.GetAsName(PdfName.TRANSFORMMETHOD)))
certification = true;
PdfName action = parameters.GetAsName(PdfName.ACTION);
if (action != null)
fieldLocks.Add(new FieldLock(action, parameters.GetAsArray(PdfName.FIELDS)));
PdfNumber p = parameters.GetAsNumber(PdfName.P);
if (p == null)
continue;
switch (p.IntValue) {
case 1:
fillInAllowed = false;
break;
case 2:
annotationsAllowed = false;
break;
}
}
}
}
示例4: PdfStream
public PdfStream(
PdfDictionary header
)
: this(header,
new bytes.Buffer())
{
}
示例5: 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();
}
示例6: LoadEncodingDifferences
/**
<summary>Loads the encoding differences into the given collection.</summary>
<param name="encodingDictionary">Encoding dictionary.</param>
<param name="codes">Encoding to alter applying differences.</param>
*/
protected void LoadEncodingDifferences(
PdfDictionary encodingDictionary,
IDictionary<ByteArray,int> codes
)
{
PdfArray differenceObjects = (PdfArray)encodingDictionary.Resolve(PdfName.Differences);
if(differenceObjects == null)
return;
/*
NOTE: Each code is the first index in a sequence of character codes to be changed.
The first character name after the code becomes the name corresponding to that code.
Subsequent names replace consecutive code indices until the next code appears
in the array or the array ends.
*/
byte[] charCodeData = new byte[1];
foreach(PdfDirectObject differenceObject in differenceObjects)
{
if(differenceObject is PdfInteger)
{charCodeData[0] = (byte)(((int)((PdfInteger)differenceObject).Value) & 0xFF);}
else // NOTE: MUST be PdfName.
{
ByteArray charCode = new ByteArray(charCodeData);
string charName = (string)((PdfName)differenceObject).Value;
if(charName.Equals(".notdef"))
{codes.Remove(charCode);}
else
{
int? code = GlyphMapping.NameToCode(charName);
codes[charCode] = (code ?? charCodeData[0]);
}
charCodeData[0]++;
}
}
}
示例7: File
public File(
)
{
Initialize();
version = VersionEnum.PDF14.GetVersion();
trailer = PrepareTrailer(new PdfDictionary());
indirectObjects = new IndirectObjects(this, null);
document = new Document(this);
}
示例8: StructureObject
/**
* Creates a StructureObject for an OBJR dictionary.
* @param structElem the parent structure element
* @param ref the reference of the parent structure element
* @param dict the object reference dictionary
*/
public StructureObject(PdfDictionary structElem, PdfIndirectReference refa, PdfDictionary dict) {
this.structElem = structElem;
this.refa = refa;
this.obj = dict.GetDirectObject(PdfName.OBJ);
this.objref = dict.GetAsIndirectObject(PdfName.OBJ);
this.structParent = ((PdfDictionary) obj).GetAsNumber(PdfName.STRUCTPARENT).IntValue;
PdfIndirectReference pg = dict.GetAsIndirectObject(PdfName.PG);
if (pg == null)
pg = structElem.GetAsIndirectObject(PdfName.PG);
this.pageref = pg.Number;
}
示例9: Decode
public override byte[] Decode(
byte[] data,
int offset,
int length,
PdfDictionary parameters
)
{
MemoryStream outputStream = new MemoryStream();
MemoryStream inputStream = new MemoryStream(data, offset, length);
DeflateStream inputFilter = new DeflateStream(inputStream, CompressionMode.Decompress);
inputStream.Position = 2; // Skips zlib's 2-byte header [RFC 1950] [FIX:0.0.8:JCT].
Transform(inputFilter,outputStream);
return DecodePredictor(outputStream.ToArray(), parameters);
}
示例10: CheckEmbeddedFile
protected override void CheckEmbeddedFile(PdfDictionary embeddedFile)
{
PdfObject _params = GetDirectObject(embeddedFile.Get(PdfName.PARAMS));
if (_params == null) {
throw new PdfAConformanceException(embeddedFile,
MessageLocalization.GetComposedMessage("embedded.file.shall.contain.valid.params.key"));
} else if (_params.IsDictionary()) {
PdfObject modDate = ((PdfDictionary) _params).Get(PdfName.MODDATE);
if (modDate == null || !(modDate is PdfString)) {
throw new PdfAConformanceException(embeddedFile,
MessageLocalization.GetComposedMessage("embedded.file.shall.contain.params.key.with.valid.moddate.key"));
}
}
}
示例11: Encode
public override byte[] Encode(
byte[] data,
int offset,
int length,
PdfDictionary parameters
)
{
MemoryStream inputStream = new MemoryStream(data, offset, length);
MemoryStream outputStream = new MemoryStream();
DeflateStream outputFilter = new DeflateStream(outputStream, CompressionMode.Compress, true);
// Add zlib's 2-byte header [RFC 1950] [FIX:0.0.8:JCT]!
outputStream.WriteByte(0x78); // CMF = {CINFO (bits 7-4) = 7; CM (bits 3-0) = 8} = 0x78.
outputStream.WriteByte(0xDA); // FLG = {FLEVEL (bits 7-6) = 3; FDICT (bit 5) = 0; FCHECK (bits 4-0) = {31 - ((CMF * 256 + FLG - FCHECK) Mod 31)} = 26} = 0xDA.
Transform(inputStream, outputFilter);
return outputStream.ToArray();
}
示例12: GetEncrypt
public PdfDictionary GetEncrypt(PdfObjectId objectId)
{
PdfDictionary encrypt = new PdfDictionary(objectId);
encrypt[PdfName.Names.Filter] = PdfName.Names.Standard;
encrypt[PdfName.Names.V] = new PdfNumeric(1);
encrypt[PdfName.Names.Length] = new PdfNumeric(40);
encrypt[PdfName.Names.R] = new PdfNumeric(2);
PdfString o = new PdfString(ownerEntry);
o.NeverEncrypt = true;
encrypt[PdfName.Names.O] = o;
PdfString u = new PdfString(userEntry);
u.NeverEncrypt = true;
encrypt[PdfName.Names.U] = u;
encrypt[PdfName.Names.P] = new PdfNumeric(permissions);
return encrypt;
}
示例13: PdfObjectStream
/// <summary>
/// Initializes a new instance from an existing dictionary. Used for object type transformation.
/// </summary>
internal PdfObjectStream(PdfDictionary dict)
: base(dict)
{
int n = Elements.GetInteger(Keys.N);
int first = Elements.GetInteger(Keys.First);
Stream.TryUnfilter();
Parser parser = new Parser(null, new MemoryStream(Stream.Value));
_header = parser.ReadObjectStreamHeader(n, first);
#if DEBUG && CORE
if (Internal.PdfDiagnostics.TraceObjectStreams)
{
Debug.WriteLine(String.Format("PdfObjectStream(document) created. Header item count: {0}", _header.GetLength(0)));
}
#endif
}
示例14: PdfCIDFont
public PdfCIDFont(PdfDocument document, PdfFontDescriptor fontDescriptor, byte[] fontData)
: base(document)
{
Elements.SetName(Keys.Type, "/Font");
Elements.SetName(Keys.Subtype, "/CIDFontType2");
PdfDictionary cid = new PdfDictionary();
cid.Elements.SetString("/Ordering", "Identity");
cid.Elements.SetString("/Registry", "Adobe");
cid.Elements.SetInteger("/Supplement", 0);
Elements.SetValue(Keys.CIDSystemInfo, cid);
FontDescriptor = fontDescriptor;
// ReSharper disable once DoNotCallOverridableMethodsInConstructor
Owner._irefTable.Add(fontDescriptor);
Elements[Keys.FontDescriptor] = fontDescriptor.Reference;
FontEncoding = PdfFontEncoding.Unicode;
}
示例15: Parse
public static PdfStream Parse(PdfDictionary dictionary, Lexical.ILexer lexer)
{
lexer.Expects("stream");
char eol = lexer.ReadChar();
if (eol == '\r')
eol = lexer.ReadChar();
if (eol != '\n')
throw new Exception(@"Parser error: stream needs to be followed by either \r\n or \n alone");
if (dictionary == null)
throw new Exception("Parser error: stream needs a dictionary");
IPdfObject lengthObject = dictionary["Length"];
if (lengthObject == null)
throw new Exception("Parser error: stream dictionary requires a Length entry");
int length = 0;
if (lengthObject is PdfIndirectReference)
{
PdfIndirectReference reference = lengthObject as PdfIndirectReference;
PdfIndirectObject lenobj = lexer.IndirectReferenceResolver
.GetObject(reference.ObjectNumber, reference.GenerationNumber);
PdfNumeric len = lenobj.Object as PdfNumeric;
length = int.Parse(len.ToString());
}
else
{
length = int.Parse(lengthObject.ToString());
}
PdfData data = PdfData.Parse(lexer, length);
lexer.Expects("endstream");
return new PdfStream(dictionary, data);
}