Ejemplo n.º 1
0
 private void SaveImages(TPdfStream DataStream, TXRefSection XRef)
 {
     int aCount = Images.Count;
     if (aCount <= 0) return;
     TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.XObjectName));
     TDictionaryRecord.BeginDictionary(DataStream);
     for (int i = 0; i < aCount; i++)
     {
         Images[i].WriteImage(DataStream, XRef);
     }
     TDictionaryRecord.EndDictionary(DataStream);
 }
Ejemplo n.º 2
0
        internal void SaveObjects(TPdfStream DataStream, TXRefSection XRef)
        {
            if (Fonts.Count > 0)
            {
                foreach (string s in Fonts.OrderedKeys)
                {
					TPdfFont pf = ((TPdfFont)Fonts[s]);
					if (pf.UsedInDoc) pf.WriteFontObject(DataStream, XRef);
                }
            }

            int aCount = Images.Count;
            for (int i = 0; i < aCount; i++)
            {
                Images[i].WriteImageObject(DataStream, XRef);
            }

            aCount = HatchPatterns.Count;
            for (int i = 0; i < aCount; i++)
            {
                HatchPatterns[i].WritePatternObject(DataStream, XRef);
            }

            if (aCount > 0)
            {
                TPdfHatch.WriteColorSpaceObject(DataStream, XRef, PatternColorSpaceId);
            }

			aCount = ImageTexturePatterns.Count;
			for (int i = 0; i < aCount; i++)
			{
				ImageTexturePatterns[i].WritePatternObject(DataStream, XRef);
			}

            aCount = GradientPatterns.Count;
            for (int i = 0; i < aCount; i++)
            {
                GradientPatterns[i].WritePatternObject(DataStream, XRef);
            }

            aCount = Functions.Count;
            for (int i = 0; i < aCount; i++)
            {
                Functions[i].WriteFunctionObject(DataStream, XRef, FCompress);
            }

            aCount = GStates.Count;
            for (int i = 0; i < aCount; i++)
            {
                GStates[i].WriteGStateObject(DataStream, XRef);
            }
        }
Ejemplo n.º 3
0
        internal static void SaveToStream(TPdfStream DataStream)
        {
            if (DataStream.HasSignature)              //Our sign algorithm requires Reader 7 or newer.
            {
                TPdfHeaderRecord.SaveToStream(DataStream, TPdfTokens.GetString(TPdfToken.Header16));
            }
            else
            {
                TPdfHeaderRecord.SaveToStream(DataStream, TPdfTokens.GetString(TPdfToken.Header14));
            }

            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.HeaderComment));
        }
Ejemplo n.º 4
0
 internal int GetId(TPdfStream DataStream, TXRefSection XRef)
 {
     if (FieldList.Count <= 0)
     {
         return(-1);                                  //We don't have any forms.
     }
     if (FId < 0)
     {
         FId = XRef.GetNewObject(DataStream);
     }
     ;
     return(FId);
 }
Ejemplo n.º 5
0
        public override void WriteFontObject(TPdfStream DataStream, TXRefSection XRef)
        {
            XRef.SetObjectOffset(FontObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, FontObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.FontName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.Type1Name));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BaseFontName, GetFontName());
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.EncodingName, EncodingType());

            TDictionaryRecord.EndDictionary(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);
        }
Ejemplo n.º 6
0
        public void Select(TPdfStream DataStream, real FontSize, ref string LastFont)
        {
            UsedInDoc = true;
            string NewFont = TPdfTokens.GetString(TPdfToken.FontPrefix) + Id.ToString(CultureInfo.InvariantCulture) + " " +
                             PdfConv.CoordsToString(FontSize) + " " + TPdfTokens.GetString(TPdfToken.CommandFont);

            if (LastFont == NewFont)
            {
                return;
            }
            LastFont = NewFont;
            TPdfBaseRecord.WriteLine(DataStream, NewFont);
        }
Ejemplo n.º 7
0
        internal int SigFieldId(TPdfStream DataStream, TXRefSection XRef)
        {
            foreach (TAcroField f in Fields)
            {
                TAcroSigField Sig = f as TAcroSigField;
                if (Sig != null)
                {
                    return(Sig.GetSigDictionaryId(DataStream, XRef));
                }
            }

            return(-1);
        }
Ejemplo n.º 8
0
        public static void UnicodeWrite(TPdfStream DataStream, string Text)
        {
            bool NeedsUnicode = false;

            for (int i = 0; i < Text.Length; i++)
            {
                if ((int)Text[i] > 128)
                {
                    NeedsUnicode = true;
                }
            }
            UnicodeWrite(DataStream, Text, NeedsUnicode, "\uFEFF");
        }
Ejemplo n.º 9
0
        internal void FinishPage(TPdfStream DataStream, TXRefSection XRef)
        {
            DataStream.FlushEndText();
            DataStream.Compress = false;
            EndStream           = DataStream.Position;
            TStreamRecord.EndSave(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            XRef.SetObjectOffset(LengthId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, LengthId);
            TPdfBaseRecord.WriteLine(DataStream, (EndStream - StartStream).ToString(CultureInfo.InvariantCulture));
            TIndirectRecord.SaveTrailer(DataStream);
        }
Ejemplo n.º 10
0
 public static void UnicodeWrite(TPdfStream DataStream, string Text, bool NeedsUnicode, string UnicodePrefix)
 {
     byte[] Buffer = null;
     if (NeedsUnicode)
     {
         Buffer = Encoding.BigEndianUnicode.GetBytes(UnicodePrefix + Text);
     }
     else
     {
         Buffer = Coder.GetBytes(Text);
     }
     Byte[] Buff2 = TPdfStringRecord.EscapeString(Buffer);
     DataStream.Write(Buff2);
 }
Ejemplo n.º 11
0
        private static void Saven0(TPdfStream DataStream, TXRefSection XRef, TPdfVisibleSignature VSig, int n0Id)
        {
            string StreamContents = "% DSBlank";

            XRef.SetObjectOffset(n0Id, DataStream);
            TIndirectRecord.SaveHeader(DataStream, n0Id);
            BeginDictionary(DataStream);
            WriteCommonXObject(DataStream, new RectangleF(0, 0, 100, 100), StreamContents);
            SaveProcSet(DataStream, XRef, false);
            EndDictionary(DataStream);
            EndDictionary(DataStream);
            WriteStream(DataStream, StreamContents);

            TIndirectRecord.SaveTrailer(DataStream);
        }
Ejemplo n.º 12
0
        public void WritePatternObject(TPdfStream DataStream, TXRefSection XRef)
        {
            XRef.SetObjectOffset(PatternObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, PatternObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.PatternName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PatternTypeName, "2");

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.MatrixName, DrawingMatrix);

            WriteShadingDictionary(DataStream, XRef);
            TDictionaryRecord.EndDictionary(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);
        }
Ejemplo n.º 13
0
        internal override void SaveToStream(TPdfStream DataStream, TXRefSection XRef, TPageInfo ParentPage)
        {
            BeginSaveToStream(DataStream, XRef);

            //Annot
            SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.AnnotName));             //Annots and Fields mix their dictionaries. See "Digital Signature Appearances" to see why annots are required even in non visible sigs.
            SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.WidgetName));

            RectangleF           Rect = new RectangleF(0, 0, 0, 0);
            TPdfVisibleSignature VSig = Signature as TPdfVisibleSignature;

            int APId = -1;

            if (VSig != null)
            {
                Rect = VSig.Rect;
                APId = SaveAPRef(DataStream, XRef);
            }

            SaveKey(DataStream, TPdfToken.RectName,
                    TPdfTokens.GetString(TPdfToken.OpenArray) +
                    String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3}", Rect.Left, Rect.Top, Rect.Right, Rect.Bottom) +
                    TPdfTokens.GetString(TPdfToken.CloseArray)
                    );

            SaveKey(DataStream, TPdfToken.PName, TIndirectRecord.GetCallObj(ParentPage.Id));
            SaveKey(DataStream, TPdfToken.FName, 132);              //bits 3 and 8

            //Field
            SaveKey(DataStream, TPdfToken.FTName, TPdfTokens.GetString(TPdfToken.SigName));
            if (Signature.Name != null)
            {
                SaveUnicodeKey(DataStream, TPdfToken.TName, Signature.Name);
            }
            SaveKey(DataStream, TPdfToken.FfName, 1);

            XRef.SetObjectOffset(GetSigDictionaryId(DataStream, XRef), DataStream);
            SaveKey(DataStream, TPdfToken.VName, TIndirectRecord.GetCallObj(SigDictionaryId));

            EndSaveToStream(DataStream, XRef);

            if (VSig != null)
            {
                SaveAPObj(DataStream, XRef, APId, VSig);
            }

            SaveSigDictionary(DataStream, XRef, SigDictionaryId);
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
0
 internal void SaveToStream(TPdfStream DataStream, TXRefSection XRef, int MDPId)
 {
     if (GetId(DataStream, XRef, MDPId) < 0)
     {
         return;
     }
     if (MDPId < 0)
     {
         return;
     }
     XRef.SetObjectOffset(PermsId, DataStream);
     TIndirectRecord.SaveHeader(DataStream, PermsId);
     BeginDictionary(DataStream);
     SaveKey(DataStream, TPdfToken.DocMDPName, TIndirectRecord.GetCallObj(MDPId));
     EndDictionary(DataStream);
     TIndirectRecord.SaveTrailer(DataStream);
 }
Ejemplo n.º 16
0
        internal void SaveToStream(TPdfStream DataStream, TXRefSection XRef, TPageInfo ParentPage)
        {
            if (FieldList.Count <= 0)
            {
                return;                                    //No AcroForm in this file.
            }
            XRef.SetObjectOffset(GetId(DataStream, XRef), DataStream);
            TIndirectRecord.SaveHeader(DataStream, FId);
            BeginDictionary(DataStream);
            SaveKey(DataStream, TPdfToken.FieldsName, FieldList.GetCallArray(DataStream, XRef, false));

            SaveKey(DataStream, TPdfToken.SigFlagsName, SigFlags);
            EndDictionary(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            FieldList.SaveToStream(DataStream, XRef, ParentPage);
        }
Ejemplo n.º 17
0
        private static void SaveProcSet(TPdfStream DataStream, TXRefSection XRef, bool HasExtraProcs)
        {
            string ExtraProcs = HasExtraProcs ?
                                TPdfTokens.NewLine + TPdfTokens.GetString(TPdfToken.TextName) + TPdfTokens.NewLine +
                                TPdfTokens.GetString(TPdfToken.ImageCName) +
                                TPdfTokens.GetString(TPdfToken.ImageIName) +
                                TPdfTokens.GetString(TPdfToken.ImageBName)
                :
                                String.Empty;

            Write(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName));
            BeginDictionary(DataStream);
            SaveKey(DataStream, TPdfToken.ProcSetName,
                    TPdfTokens.GetString(TPdfToken.OpenArray) +
                    TPdfTokens.GetString(TPdfToken.PDFName) + ExtraProcs +
                    TPdfTokens.GetString(TPdfToken.CloseArray)
                    );
        }
Ejemplo n.º 18
0
        public static void BeginSave(TPdfStream DataStream, int LengthId, bool Compress, int Length1)
        {
            TDictionaryRecord.BeginDictionary(DataStream);
            Write(DataStream, TPdfTokens.GetString(TPdfToken.LengthName) + " ");
            TIndirectRecord.CallObj(DataStream, LengthId);

            if (Length1 >= 0)
            {
                WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.Length1Name) + " " + Length1.ToString(CultureInfo.InvariantCulture));
            }

            if (Compress)
            {
                SetFlateDecode(DataStream);
            }
            TDictionaryRecord.EndDictionary(DataStream);
            BeginSave(DataStream);
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
        private void SaveWidths(TPdfStream DataStream)
        {
            //Docs say it is prefered to save as indirect object, but acrobat writes it directly.
            //Widths object.
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.WidthsName) + " " + TPdfTokens.GetString(TPdfToken.OpenArray));
            int fc = FirstChar; if (fc < 0)

            {
                fc = 0;
            }

            for (int i = fc; i <= LastChar; i++)         //characters on winansi are NOT the same as in low byte unicode.  For example char 0x92 (146) is a typographic ' in winansi, not defined in unicode.
            {
                int z = (int)CharUtils.GetUniFromWin1252_PDF((byte)i);
                TPdfBaseRecord.WriteLine(DataStream, PdfConv.CoordsToString(Math.Round(FTrueTypeData.GlyphWidth(FTrueTypeData.Glyph(z, false)))));                 //don't log the erorr here, character doesn't need to exist.
            }

            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.CloseArray));
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        public static void WriteStringInStream(TPdfStream DataStream, string Text, real FontSize, TPdfFont aFont, ref string LastFont, string EndNewText, string StartNewText2, string EndNewText2, TTracedFonts TracedFonts)
        {
            TPdfFont LastFallbackFont = aFont;
            int      StartText        = 0;

            int TLen = Text.Length;

            for (int i = 0; i <= TLen; i++)
            {
                TPdfFont FallbackFont = null;

                if (i < TLen)
                {
                    FallbackFont = aFont.Fallback(Text[i], 0);
                    if (FallbackFont == null)
                    {
                        FallbackFont = aFont;
                    }
                }

                if (FallbackFont != LastFallbackFont)
                {
                    WriteSimpleString(DataStream, Text.Substring(StartText, i - StartText), LastFallbackFont, EndNewText);

                    StartText = i;

                    if (FallbackFont != null)
                    {
                        TPdfBaseRecord.Write(DataStream, EndNewText2);
                        FallbackFont.Select(DataStream, FontSize, ref LastFont);

                        if (FlexCelTrace.HasListeners && FallbackFont != aFont && !TracedFonts.ContainsKey(aFont.FontName + ";" + FallbackFont.FontName))
                        {
                            TracedFonts.Add(aFont.FontName + ";" + FallbackFont.FontName, String.Empty);
                            FlexCelTrace.Write(new TPdfUsedFallbackFontError(FlxMessages.GetString(FlxErr.ErrUsedFallbackFont, aFont.FontName, FallbackFont.FontName), aFont.FontName, FallbackFont.FontName));
                        }

                        TPdfBaseRecord.Write(DataStream, StartNewText2);
                        LastFallbackFont = FallbackFont;
                    }
                }
            }
        }
Ejemplo n.º 23
0
        internal override void SaveToStream(TPdfStream DataStream, TXRefSection XRef)
        {
            BeginSaveToStream(DataStream, XRef);
            SaveKey(DataStream, TPdfToken.SubtypeName, "/" + FCommentProperties.CommentType.ToString());
            SaveUnicodeKey(DataStream, TPdfToken.ContentsName, FComment);
            SaveKey(DataStream, TPdfToken.NameName, "/" + FCommentProperties.Icon.ToString());
            SaveKey(DataStream, TPdfToken.CAName, PdfConv.DoubleToString(FCommentProperties.Opacity));
            if (FCommentProperties.CommentType != TPdfCommentType.Text)
            {
                Color  aColor  = FCommentProperties.BackgroundColor;
                string BgColor = TPdfTokens.GetString(TPdfToken.OpenArray) +
                                 PdfConv.CoordsToString(aColor.R / 255.0) + " " +
                                 PdfConv.CoordsToString(aColor.G / 255.0) + " " +
                                 PdfConv.CoordsToString(aColor.B / 255.0) +
                                 TPdfTokens.GetString(TPdfToken.CloseArray);

                SaveKey(DataStream, TPdfToken.ICName, BgColor);
            }
            EndSaveToStream(DataStream, XRef);
        }
Ejemplo n.º 24
0
        //For unicode fonts, we actually need to write 2 fonts, one type 0 and one CID.
        public override void WriteFontObject(TPdfStream DataStream, TXRefSection XRef)
        {
            //Save Type 0 Font.
            XRef.SetObjectOffset(FontObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, FontObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.FontName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.Type0Name));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BaseFontName, GetFontName(true, Subset));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.EncodingName, EncodingType());

            XRef.SetObjectOffset(CIDFontId, DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.DescendantFontsName,
                                      TPdfTokens.GetString(TPdfToken.OpenArray) + TIndirectRecord.GetCallObj(CIDFontId) + TPdfTokens.GetString(TPdfToken.CloseArray));

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.ToUnicodeName, TIndirectRecord.GetCallObj(ToUnicodeId));

            TDictionaryRecord.EndDictionary(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            //Save CID Font.
            XRef.SetObjectOffset(CIDFontId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, CIDFontId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.FontName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.CIDFontType2Name));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BaseFontName, GetFontName(true, Subset));
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.CIDSystemInfo));
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.CIDToGIDMap));

            SaveWidths(DataStream);

            XRef.SetObjectOffset(FontDescriptorId, DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FontDescriptorName, TIndirectRecord.GetCallObj(FontDescriptorId));

            TDictionaryRecord.EndDictionary(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            SaveToUnicode(DataStream, XRef);
            SaveFontDescriptor(DataStream, FontDescriptorId, XRef, true, Subset);
        }
Ejemplo n.º 25
0
        private static void SaveFRM(TPdfStream DataStream, TXRefSection XRef, TPdfVisibleSignature VSig, int FRMId)
        {
            string StreamContents = "q 1 0 0 1 0 0 cm /n0 Do Q" + TPdfTokens.NewLine + "q 1 0 0 1 0 0 cm /n2 Do Q";

            XRef.SetObjectOffset(FRMId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, FRMId);
            BeginDictionary(DataStream);
            WriteCommonXObject(DataStream, VSig.Rect, StreamContents);
            int n0Id = XRef.GetNewObject(DataStream);
            int n2Id = XRef.GetNewObject(DataStream);

            SaveProcSet(DataStream, XRef, false);
            SaveResourcesSecondXObject(DataStream, n0Id, n2Id);
            EndDictionary(DataStream);
            WriteStream(DataStream, StreamContents);

            TIndirectRecord.SaveTrailer(DataStream);

            Saven0(DataStream, XRef, VSig, n0Id);
            Saven2(DataStream, XRef, VSig, n2Id);
        }
Ejemplo n.º 26
0
        internal void SaveToStream(TPdfStream DataStream)
        {
            FStartPosition = DataStream.Position;
            string Generation = " 00000 n ";

            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.XRef));
            TPdfBaseRecord.WriteLine(DataStream, "0 " + (FList.Count + 1).ToString(CultureInfo.InvariantCulture));
            int aCount = FList.Count;

            TPdfBaseRecord.WriteLine(DataStream, "0000000000 65535 f ");

            for (int i = 0; i < aCount; i++)
            {
                TPdfBaseRecord.WriteLine(DataStream, (
#if (!FRAMEWORK20)
                                             (long)
#endif
                                             FList[i]).ToString("0000000000", CultureInfo.InvariantCulture) +
                                         Generation);
            }
        }
Ejemplo n.º 27
0
        private static void SaveAPObj(TPdfStream DataStream, TXRefSection XRef, int APId, TPdfVisibleSignature VSig)
        {
            string StreamContents = "q 1 0 0 1 0 0 cm /FRM Do Q";

            //AP Object
            XRef.SetObjectOffset(APId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, APId);
            BeginDictionary(DataStream);
            WriteCommonXObject(DataStream, VSig.Rect, StreamContents);
            int FRMId = XRef.GetNewObject(DataStream);

            SaveProcSet(DataStream, XRef, false);
            SaveResourcesFirstXObject(DataStream, XRef, FRMId);
            EndDictionary(DataStream);

            WriteStream(DataStream, StreamContents);

            TIndirectRecord.SaveTrailer(DataStream);

            SaveFRM(DataStream, XRef, VSig, FRMId);
        }
Ejemplo n.º 28
0
 internal static void SaveToStream(TPdfStream DataStream, int PageListId, TPageInfo PageInfo, TAcroFormRecord AcroForm, TXRefSection XRef, int PageNumber, int PageCount)
 {
     XRef.SetObjectOffset(PageInfo.Id, DataStream);
     TIndirectRecord.SaveHeader(DataStream, PageInfo.Id);
     BeginDictionary(DataStream);
     SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.PageName));
     SaveKey(DataStream, TPdfToken.ParentName, TIndirectRecord.GetCallObj(PageListId));
     SaveKey(DataStream, TPdfToken.ContentsName, TIndirectRecord.GetCallObj(PageInfo.Contents.Id));
     SaveKey(DataStream, TPdfToken.MediaBoxName,
             TPdfTokens.GetString(TPdfToken.OpenArray) +
             "0 0 " +
             PdfConv.CoordsToString(PageInfo.Contents.PageSize.Width * 72 / 100) + " " +
             PdfConv.CoordsToString(PageInfo.Contents.PageSize.Height * 72 / 100) +
             TPdfTokens.GetString(TPdfToken.CloseArray)
             );
     if (PageInfo.Annots.HasAnnots(AcroForm, PageNumber, PageCount))
     {
         SaveKey(DataStream, TPdfToken.AnnotsName, PageInfo.Annots.GetCallArray(DataStream, XRef, AcroForm, PageNumber, PageCount));
     }
     EndDictionary(DataStream);
     TIndirectRecord.SaveTrailer(DataStream);
 }
Ejemplo n.º 29
0
        private void SaveFonts(TPdfStream DataStream, TXRefSection XRef)
        {
            int aCount = Fonts.Count;
            if (aCount <= 0) return;
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.FontName));
            TDictionaryRecord.BeginDictionary(DataStream);

            Fonts.CreateOrderedKeys();
            foreach (string s in Fonts.Keys)
            {
                Fonts.OrderedKeys.Add(s);
            }

            Fonts.OrderedKeys.Sort(); //to keep the reference pdfs always the same.

            foreach (string s in Fonts.OrderedKeys)
            {
                TPdfFont pf = ((TPdfFont)Fonts[s]);
				if (pf.UsedInDoc) pf.WriteFont(DataStream, XRef);
            }
            TDictionaryRecord.EndDictionary(DataStream);
        }
Ejemplo n.º 30
0
        public void WriteSMaskObject(TPdfStream DataStream, TXRefSection XRef)
        {
            //Actually write stream
            XRef.SetObjectOffset(SMaskObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, SMaskObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, SMask.Length);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.XObjectName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.FormName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, BBox);
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.GroupName));
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SName, TPdfTokens.GetString(TPdfToken.TransparencyName));

            TDictionaryRecord.EndDictionary(DataStream);

            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            TStreamRecord.Write(DataStream, SMask);
            TStreamRecord.EndSave(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);
        }