public PdfGoTo createInternalLinkGoTo(string id, PdfObjectId objectId) { IDNode node = (IDNode)idReferences[id]; node.CreateInternalLinkGoTo(objectId); return(node.GetInternalLinkGoTo()); }
public PdfGoTo(PdfObjectReference pageReference, PdfObjectId objectId) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Action; this[PdfName.Names.S] = PdfName.Names.GoTo; this.pageReference = pageReference; }
/// <summary> /// Encrypts the passed byte array using the ARC4 cipher. /// </summary> public byte[] Encrypt(byte[] data, PdfObjectId objectId) { Arc4 arc4 = new Arc4(ComputeEncryptionKey31(masterKey, objectId)); arc4.Encrypt(data, data); return(data); }
public PdfPageTree(PdfObjectId objectId) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Pages; this.kids = new PdfArray(); this[PdfName.Names.Kids] = kids; }
/// <summary> /// Computes an encryption key that is used to encrypt string and stream data /// in the PDF document. /// </summary> /// <remarks> /// Corresponds to algorithm 3.1 in section 3.5 of the PDF specficiation. /// </remarks> private static byte[] ComputeEncryptionKey31( byte[] masterKey, PdfObjectId objectId) { byte[] key = new byte[masterKey.Length + 5]; // Compute a hash based on: // a) The master key Array.Copy(masterKey, 0, key, 0, masterKey.Length); int pos = masterKey.Length; // b) The low order 3 bytes of the object number. key[pos++] = (byte)(objectId.ObjectNumber & 0xff); key[pos++] = (byte)((objectId.ObjectNumber >> 8) & 0xff); key[pos++] = (byte)((objectId.ObjectNumber >> 16) & 0xff); // b) The low order 2 bytes of the generation number. key[pos++] = (byte)(objectId.GenerationNumber & 0xff); key[pos++] = (byte)((objectId.GenerationNumber >> 8) & 0xff); MD5 md5 = MD5.Create(); byte[] hash = md5.ComputeHash(key); // The first n+5 bytes of the computed hash consitute the encryption key. Array.Copy(hash, 0, key, 0, masterKey.Length + 5); return(key); }
public PdfXObject(byte[] objectData, PdfName name, PdfObjectId objectId) : base(objectId) { this.objectData = objectData; this.name = name; dictionary[PdfName.Names.Type] = PdfName.Names.XObject; }
public PdfFontDescriptor( string fontName, PdfObjectId objectId) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Font; this[PdfName.Names.FontName] = new PdfName(fontName); }
public PdfType1Font( PdfObjectId objectId, string fontName, string baseFont) : base(fontName, objectId) { this[PdfName.Names.Subtype] = PdfName.Names.Type1; this[PdfName.Names.BaseFont] = new PdfName(baseFont); }
public IndirectObject CreateInstance(PdfObjectId objectId, PdfObject referencedObject, bool isReadOnly) { var objectType = referencedObject.GetType(); var genCtor = ctorCache.GetOrAdd(objectType, GetConstructorForType); return((IndirectObject)genCtor.Invoke(new object[] { objectId, referencedObject, isReadOnly })); }
/// <param name="objectId"> /// A unique object number. /// </param> /// <param name="fontName"> /// The name by which the font is reference in the Font subdictionary /// </param> /// <param name="baseFont"> /// The PostScript name of the font. /// </param> public PdfTrueTypeFont(PdfObjectId objectId, string fontName, string baseFont) : base(fontName, objectId) { this[PdfName.Names.Subtype] = PdfName.Names.TrueType; this[PdfName.Names.BaseFont] = new PdfName(baseFont); this[PdfName.Names.FirstChar] = new PdfNumeric(0); this[PdfName.Names.LastChar] = new PdfNumeric(255); }
public PdfGoToRemote(PdfFileSpec fileSpec, PdfObjectId objectId) : base(objectId) { this.fileSpec = fileSpec; this[PdfName.Names.Type] = PdfName.Names.Action; this[PdfName.Names.S] = PdfName.Names.GoToR; this[PdfName.Names.F] = fileSpec.GetReference(); this[PdfName.Names.D] = DefaultDestination; }
public PdfCIDFont( PdfObjectId objectId, PdfFontSubTypeEnum subType, string baseFont) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Font; this[PdfName.Names.Subtype] = new PdfName(subType.ToString()); this[PdfName.Names.BaseFont] = new PdfName(baseFont); this[PdfName.Names.DW] = new PdfNumeric(1000); this[PdfName.Names.CIDToGIDMap] = PdfName.Names.Identity; }
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; }
internal void CreateInternalLinkGoTo(PdfObjectId objectId) { if (internalLinkGoToPageReference == null) { internalLinkGoTo = new PdfGoTo(null, objectId); } else { internalLinkGoTo = new PdfGoTo(internalLinkGoToPageReference, objectId); } if (xPosition != 0) { internalLinkGoTo.X = xPosition; internalLinkGoTo.Y = yPosition; } }
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); }
public PdfPage( PdfResources resources, PdfContentStream contents, int pagewidth, int pageheight, PdfObjectId objectId) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Page; this[PdfName.Names.Resources] = resources.GetReference(); this[PdfName.Names.Contents] = contents.GetReference(); PdfArray mediaBox = new PdfArray(); mediaBox.Add(new PdfNumeric(0)); mediaBox.Add(new PdfNumeric(0)); mediaBox.Add(new PdfNumeric(pagewidth)); mediaBox.Add(new PdfNumeric(pageheight)); this[PdfName.Names.MediaBox] = mediaBox; }
/// <summary> /// Instanciates a new IndirectObject /// </summary> /// <param name="objectId">The <see cref="PdfObjectId"/> of the referenced object</param> /// <param name="referencedObject">Referenced <see cref="PdfObject"/></param> /// <param name="isReadOnly">True if object is read-only, otherwise false.</param> protected IndirectObject(PdfObjectId objectId, PdfObject referencedObject, bool isReadOnly) : base(isReadOnly) { this.objectId = objectId; this.referencedObject = referencedObject; }
/// <summary> /// Instanciates a new IndirectObject /// </summary> /// <param name="objectId">The <see cref="PdfObjectId"/> of the referenced object</param> /// <param name="referencedObject">Referenced <see cref="PdfObject"/></param> protected IndirectObject(PdfObjectId objectId, PdfObject referencedObject) { this.objectId = objectId; this.referencedObject = referencedObject; }
public PdfAnnotList(PdfObjectId objectId) : base(objectId) { }
/// <summary> /// Adds an entry to the table. /// </summary> public void Add(PdfObjectId objectId, long offset) { section.Add(objectId, offset); }
public PdfResources(PdfObjectId objectId) : base(objectId) { this[PdfName.Names.ProcSet] = DefaultProcedureSets; }
public PdfBoolean(bool val, PdfObjectId objectId) : base(objectId) { this.val = val; }
/// <summary> /// Computes an encryption key that is used to encrypt string and stream data /// in the PDF document. /// </summary> /// <remarks> /// Corresponds to algorithm 3.1 in section 3.5 of the PDF specficiation. /// </remarks> private static byte[] ComputeEncryptionKey31( byte[] masterKey, PdfObjectId objectId) { byte[] key = new byte[masterKey.Length + 5]; // Compute a hash based on: // a) The master key Array.Copy(masterKey, 0, key, 0, masterKey.Length); int pos = masterKey.Length; // b) The low order 3 bytes of the object number. key[pos++] = (byte)(objectId.ObjectNumber & 0xff); key[pos++] = (byte)((objectId.ObjectNumber >> 8) & 0xff); key[pos++] = (byte)((objectId.ObjectNumber >> 16) & 0xff); // b) The low order 2 bytes of the generation number. key[pos++] = (byte)(objectId.GenerationNumber & 0xff); key[pos++] = (byte)((objectId.GenerationNumber >> 8) & 0xff); MD5 md5 = MD5.Create(); byte[] hash = md5.ComputeHash(key); // The first n+5 bytes of the computed hash consitute the encryption key. Array.Copy(hash, 0, key, 0, masterKey.Length + 5); return key; }
public PdfCatalog(PdfObjectId objectId) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Catalog; }
/// <summary> /// Instanciates a new IndirectReference /// </summary> /// <param name="objectId">Referenced <see cref="PdfObjectId"/></param> public IndirectReference(PdfObjectId objectId) : base(objectId, null) { }
/// <summary> /// Adds an entry to the section. /// </summary> internal void Add(PdfObjectId objectId, long offset) { subsection.Add(objectId, offset); }
public PdfICCStream(PdfObjectId id, byte[] profileData) : base(id) { this.data = profileData; }
/// <summary> /// Instanciates a new PDF object reference. /// </summary> /// <param name="objectId">The referenced object's <see cref="PdfObjectId"/>.</param> protected PdfObjectReferenceBase(PdfObjectId objectId) { this.objectId = objectId; }
/// <summary> /// Encrypts the passed byte array using the ARC4 cipher. /// </summary> public byte[] Encrypt(byte[] data, PdfObjectId objectId) { Arc4 arc4 = new Arc4(ComputeEncryptionKey31(masterKey, objectId)); arc4.Encrypt(data, data); return data; }
public PdfFont(string fontname, PdfObjectId objectId) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.Font; this[PdfName.Names.Name] = new PdfName(fontname); }
public PdfFileSpec(PdfObjectId objectId, string filename) : base(objectId) { this[PdfName.Names.Type] = PdfName.Names.FileSpec; this[PdfName.Names.F] = new PdfString(filename); }
public PdfNumeric(decimal val, PdfObjectId objectId) : base(objectId) { this.val = val; }
public PdfInfo(PdfObjectId objectId) : base(objectId) { }
/// <summary> /// Reads next <see cref="PdfObject"/> from PDF stream. /// </summary> /// <param name="reader">The <see cref="PdfReader"/> to use.</param> /// <returns>Read PdfObject.</returns> public static PdfObject ReadObject(this PdfReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } reader.MoveToNonWhiteSpace(); char firstChar = reader.Peek(); switch (firstChar) { case '%': // Skip comment reader.SkipWhile(c => !Chars.IsEndOfLine(c)); reader.SkipWhile(Chars.IsEndOfLine); // Then try read next object return(ReadObject(reader)); case 't': reader.ReadToken(BooleanObject.TrueToken); return(new BooleanObject(true, true)); case 'f': reader.ReadToken(BooleanObject.FalseToken); return(new BooleanObject(false, true)); case 'n': reader.ReadToken(NullObject.NullToken); return(new NullObject()); case '(': return(LiteralStringObject.FromReader(reader)); case '<': if (reader.Peek(1) == '<') { return(DictionaryObject.FromReader(reader)); } else { return(HexadecimalStringObject.FromReader(reader)); } case '/': return(NameObject.FromReader(reader)); case '[': return(ArrayObject.FromReader(reader)); case '+': case '-': return(NumericObject.FromReader(reader)); } if (char.IsDigit(firstChar)) { int indRefLength = IsIndirectReference(reader); if (indRefLength >= 5) { var indRefStr = reader.ReadString(indRefLength); var objectId = PdfObjectId.FromString(indRefStr.Substring(0, indRefLength - 2)); return(new IndirectReference(objectId)); } return(NumericObject.FromReader(reader)); } throw new NotImplementedException(); }