Example #1
0
        protected void BeginSaveToStream(TPdfStream DataStream, TXRefSection XRef)
        {
            XRef.SetObjectOffset(FId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, FId);
            BeginDictionary(DataStream);
            SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.AnnotName));
            SaveKey(DataStream, TPdfToken.RectName,
                    TPdfTokens.GetString(TPdfToken.OpenArray) +
                    String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3}", x1, y1, x1 + Width, y1 + Height) +
                    TPdfTokens.GetString(TPdfToken.CloseArray)
                    );

            DateTime dt = DateTime.Now;

            SaveKey(DataStream, TPdfToken.MName, TDateRecord.GetDate(dt));
        }
Example #2
0
        internal void SaveToStream(TPdfStream DataStream, TXRefSection XRef, TPdfProperties p)
        {
            InfoId = XRef.GetNewObject(DataStream);
            TIndirectRecord.SaveHeader(DataStream, InfoId);
            BeginDictionary(DataStream);
            if (p.Title != null && p.Title.Length > 0)
            {
                SaveUnicodeKey(DataStream, TPdfToken.TitleName, p.Title);
            }
            if (p.Author != null && p.Author.Length > 0)
            {
                SaveUnicodeKey(DataStream, TPdfToken.AuthorName, p.Author);
            }
            if (p.Subject != null && p.Subject.Length > 0)
            {
                SaveUnicodeKey(DataStream, TPdfToken.SubjectName, p.Subject);
            }
            if (p.Keywords != null && p.Keywords.Length > 0)
            {
                SaveUnicodeKey(DataStream, TPdfToken.KeywordsName, p.Keywords);
            }
            if (p.Creator != null && p.Creator.Length > 0)
            {
                SaveUnicodeKey(DataStream, TPdfToken.CreatorName, p.Creator);
            }

            string Producer = TPdfTokens.GetString(TPdfToken.Producer);

            if (!PdfWriter.FTesting)
            {
                Producer += Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }

            if (Producer != null && Producer.Length > 0)
            {
                SaveUnicodeKey(DataStream, TPdfToken.ProducerName, Producer);
            }

            DateTime dt = DateTime.Now;

            SaveKey(DataStream, TPdfToken.CreationDateName, TDateRecord.GetDate(dt));
            EndDictionary(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);
        }
Example #3
0
        private void SaveSigDictionary(TPdfStream DataStream, TXRefSection XRef, int SigDictionaryId)
        {
            XRef.SetObjectOffset(SigDictionaryId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, SigDictionaryId);
            BeginDictionary(DataStream);

            SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.SigName));
            SaveKey(DataStream, TPdfToken.FilterName, TPdfTokens.GetString(TPdfToken.Adobe_PPKLiteName));
            SaveKey(DataStream, TPdfToken.SubFilterName, TPdfTokens.GetString(TPdfToken.adbe_pkcs7_detachedName));

            DateTime dt = Signature.SignDate;

            if (dt == DateTime.MinValue)
            {
                dt = DateTime.Now;
            }
            SaveKey(DataStream, TPdfToken.MName, TDateRecord.GetDate(dt));

            if (Signature.Location != null)
            {
                SaveUnicodeKey(DataStream, TPdfToken.LocationName, Signature.Location);
            }
            if (Signature.Reason != null)
            {
                SaveUnicodeKey(DataStream, TPdfToken.ReasonName, Signature.Reason);
            }
            if (Signature.ContactInfo != null)
            {
                SaveUnicodeKey(DataStream, TPdfToken.ContactInfoName, Signature.ContactInfo);
            }

            Write(DataStream, TPdfTokens.GetString(TPdfToken.ContentsName)); //After writing "contents" we need to write the pkcs data, but it can not be written yet since we didn't calculate it.

            PKCSSize = DataStream.GetEstimatedLength() * 2 + 2;              //*2 +2 is because the real string will be hexa, and each byte is 2 bytes, plus "<" and ">" to mark an hexa string.

            int SignOffset = 50 + PKCSSize;                                  //The 50 is for /Contents[a b c d] where a, b, c and d are of variable length.

            DataStream.GoVirtual(SignOffset);

            SaveReferenceDict(DataStream, XRef);

            EndSaveToStream(DataStream, XRef);
        }