Beispiel #1
0
        public TPdfInternalFont(Font aFont, int aId, bool aUseKerning, TPdfResources aResources) : base(aFont, aId, aUseKerning, aResources)
        {
            //LOGFONT lf = new LOGFONT();  This does not work, and it is unmanaged also!

            string FontName = ";" + aFont.Name.Replace(" ", String.Empty).ToUpper(CultureInfo.InvariantCulture) + ";";

            if (TPdfTokens.GetString(TPdfToken.StSymbolFonts).IndexOf(FontName) >= 0)
            {
                FFontName = TPdfTokens.GetString(TPdfToken.PsSymbol);
                FFontType = TFontType.Symbol;
            }
            else
            if (TPdfTokens.GetString(TPdfToken.StSerifFonts).IndexOf(FontName) >= 0)
            {
                FFontName = TPdfTokens.GetString(TPdfToken.PsTimes);
                FFontType = TFontType.Times;
            }
            else
            if (TPdfTokens.GetString(TPdfToken.StFixedFonts).IndexOf(FontName) >= 0)
            {
                FFontName = TPdfTokens.GetString(TPdfToken.PsCourier);
                FFontType = TFontType.Courier;
            }
            else
            {
                FFontName = TPdfTokens.GetString(TPdfToken.PsHelvetica);
                FFontType = TFontType.Helvetica;
            }

            Width = TInternalFontMetrics.Width(FFontType, FFontStyle);
            if (FUseKerning)
            {
                Kern = TInternalFontMetrics.Kern(FFontType, FFontStyle);
            }
        }
Beispiel #2
0
 public static void SetFlateDecode(TPdfStream DataStream)
 {
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.FilterName,
                               TPdfTokens.GetString(TPdfToken.OpenArray) +
                               TPdfTokens.GetString(TPdfToken.FlateDecodeName) +
                               TPdfTokens.GetString(TPdfToken.CloseArray));
 }
Beispiel #3
0
        protected string GetFontName(bool Embed, bool Subset)
        {
            string Result = "/";

            if (Subset && Embed)
            {
                Result += "ABGVAA+";
            }
            Result += FTrueTypeData.PostcriptName;
            if ((AdditionalStyle & FontStyle.Italic) != 0)
            {
                if ((AdditionalStyle & FontStyle.Bold) != 0)
                {
                    Result += TPdfTokens.GetString(TPdfToken.BoldItalic);
                }
                else
                {
                    Result += TPdfTokens.GetString(TPdfToken.Italic);
                }
            }
            else
            if ((AdditionalStyle & FontStyle.Bold) != 0)
            {
                Result += TPdfTokens.GetString(TPdfToken.Bold);
            }

            return(Result);
        }
Beispiel #4
0
        private void SavePatterns(TPdfStream DataStream, TXRefSection XRef)
        {
			int HatchCount = HatchPatterns.Count;
			int ImageTextureCount = ImageTexturePatterns.Count;
			int GradientCount = GradientPatterns.Count;
            if (HatchCount + GradientCount + ImageTextureCount <= 0) return;
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.PatternName));
			TDictionaryRecord.BeginDictionary(DataStream);
			for (int i = 0; i < HatchCount; i++)
			{
				HatchPatterns[i].WritePattern(DataStream, XRef);
			}

			for (int i = 0; i < ImageTextureCount; i++)
			{
				ImageTexturePatterns[i].WritePattern(DataStream, XRef);
			}
            
            for (int i = 0; i < GradientCount; i++)
            {
                GradientPatterns[i].WritePattern(DataStream, XRef);
            }

            TDictionaryRecord.EndDictionary(DataStream);
            if (HatchCount <= 0) return;

            //Pattern color space
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ColorSpaceName));
            TDictionaryRecord.BeginDictionary(DataStream);
            PatternColorSpaceId = TPdfHatch.WriteColorSpace(DataStream, XRef);
            TDictionaryRecord.EndDictionary(DataStream);
        }
Beispiel #5
0
        internal string GetCallArray(TPdfStream DataStream, TXRefSection XRef, bool OnlySignatures)
        {
            StringBuilder sb     = new StringBuilder();
            int           aCount = Count;

            for (int i = 0; i < aCount; i++)
            {
                int id = Fields[i].GetId(DataStream, XRef, OnlySignatures);
                if (id < 0)
                {
                    continue;
                }
                if (sb.Length > 0)
                {
                    sb.Append(" ");
                }
                sb.Append(TIndirectRecord.GetCallObj(id));
            }
            if (sb.Length == 0)
            {
                return(String.Empty);
            }

            if (OnlySignatures)
            {
                return(sb.ToString());
            }

            return(TPdfTokens.GetString(TPdfToken.OpenArray) + sb.ToString()
                   + TPdfTokens.GetString(TPdfToken.CloseArray));
        }
Beispiel #6
0
        protected void SaveFontDescriptor(TPdfStream DataStream, int FontDescriptorId, TXRefSection XRef, bool Embed, bool Subset)
        {
            XRef.SetObjectOffset(FontDescriptorId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, FontDescriptorId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.FontDescriptorName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FontNameName, GetFontName(Embed, Subset));

            string BBox =
                TPdfTokens.GetString(TPdfToken.OpenArray) +
                FTrueTypeData.BoundingBox.GetBBox(FTrueTypeData.UnitsPerEm) +
                TPdfTokens.GetString(TPdfToken.CloseArray);

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FontBBoxName, BBox);

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FontAscentName, (int)Math.Round(FTrueTypeData.Ascent * 1000F / FTrueTypeData.UnitsPerEm));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FontDescentName, (int)Math.Round(FTrueTypeData.Descent * 1000F / FTrueTypeData.UnitsPerEm));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.CapHeightName, (int)Math.Round(FTrueTypeData.CapHeight * 1000F / FTrueTypeData.UnitsPerEm));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.ItalicAngleName, FTrueTypeData.ItalicAngle.ToString(CultureInfo.InvariantCulture));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.StemVName, 80);             //StemV info is not present on a true type font. 80 seems to be what adobe writes.

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FlagsName, FTrueTypeData.FontFlags);

            if (Embed)
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.FontFile2Name, TIndirectRecord.GetCallObj(EmbeddedData.GetStreamId(DataStream, XRef)));
            }


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

            EmbeddedData.WriteFont(DataStream, XRef, FCompress);
        }
Beispiel #7
0
 internal static void SaveToStream(TPdfStream DataStream, TXRefSection XRef, int CatalogId, int PagesId, int BookmarksId, int AcroFormId, int PermsId, TPdfToken PageLayout)
 {
     XRef.SetObjectOffset(CatalogId, DataStream);
     TIndirectRecord.SaveHeader(DataStream, CatalogId);
     TDictionaryRecord.BeginDictionary(DataStream);
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.CatalogName));
     SaveKey(DataStream, TPdfToken.PagesName, TIndirectRecord.GetCallObj(PagesId));
     if (BookmarksId >= 0)
     {
         SaveKey(DataStream, TPdfToken.OutlinesName, TIndirectRecord.GetCallObj(BookmarksId));
     }
     if (PageLayout != TPdfToken.None)
     {
         SaveKey(DataStream, TPdfToken.PageModeName, TPdfTokens.GetString(PageLayout));
     }
     if (AcroFormId >= 0)
     {
         SaveKey(DataStream, TPdfToken.AcroFormName, TIndirectRecord.GetCallObj(AcroFormId));
     }
     if (PermsId >= 0)
     {
         SaveKey(DataStream, TPdfToken.PermsName, TIndirectRecord.GetCallObj(PermsId));
     }
     EndDictionary(DataStream);
     TIndirectRecord.SaveTrailer(DataStream);
 }
Beispiel #8
0
        internal void SaveToStream(TPdfStream DataStream, TXRefSection XRef, TAcroFormRecord AcroForm)
        {
            XRef.SetObjectOffset(Id, DataStream);
            TIndirectRecord.SaveHeader(DataStream, Id);
            BeginDictionary(DataStream);
            SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.PagesName));

            SaveKids(DataStream, XRef);

            SaveKey(DataStream, TPdfToken.CountName, FList.Count);
            WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName));
            Resources.SaveResourceDesc(DataStream, XRef, true);
            EndDictionary(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            int aCount = FList.Count;

            for (int i = 0; i < aCount; i++)
            {
                TPageInfo PInfo = FList[i];
                TPageRecord.SaveToStream(DataStream, Id, PInfo, AcroForm, XRef, i, aCount);
                PInfo.Annots.SaveToStream(DataStream, XRef);
            }

            Resources.SaveObjects(DataStream, XRef);
        }
Beispiel #9
0
        internal string GetCallArray(TPdfStream DataStream, TXRefSection XRef, TAcroFormRecord AcroForm, int PageNumber, int PageCount)
        {
            StringBuilder sb     = new StringBuilder();
            int           aCount = Count;

            for (int i = 0; i < aCount; i++)
            {
                int id = Annots[i].GetId(DataStream, XRef);
                if (i > 0)
                {
                    sb.Append(" ");
                }
                sb.Append(TIndirectRecord.GetCallObj(id));
            }

            string SignatureFields = AcroForm.GetSignatureFieldsCallArray(DataStream, XRef, PageNumber, PageCount);             //Signature Fields are also widget annotations.

            if (SignatureFields.Length > 0)
            {
                sb.Append(" ");
                sb.Append(SignatureFields);
            }

            if (sb.Length == 0)
            {
                return(String.Empty);
            }
            return(TPdfTokens.GetString(TPdfToken.OpenArray) + sb.ToString()
                   + TPdfTokens.GetString(TPdfToken.CloseArray));
        }
Beispiel #10
0
        private static void Saven2(TPdfStream DataStream, TXRefSection XRef, TPdfVisibleSignature VSig, int n2Id)
        {
            string s = String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4} {5} cm ",
                                     VSig.Rect.Width,
                                     0, 0,
                                     VSig.Rect.Height,
                                     0, 0);

            string StreamContents = "q " + s + TPdfTokens.GetString(TPdfToken.ImgPrefix) + "0 Do Q";

            XRef.SetObjectOffset(n2Id, DataStream);
            TIndirectRecord.SaveHeader(DataStream, n2Id);
            BeginDictionary(DataStream);
            WriteCommonXObject(DataStream, VSig.Rect, StreamContents);

            TPdfResources Resources = new TPdfResources(null, false, null);

            using (MemoryStream ImgStream = new MemoryStream(VSig.ImageData))
            {
                Resources.AddImage(null, ImgStream, FlxConsts.NoTransparentColor, false);
            }

            SaveProcSet(DataStream, XRef, true);
            SaveResourcesImgXObject(DataStream, XRef, Resources);

            EndDictionary(DataStream);
            WriteStream(DataStream, StreamContents);

            TIndirectRecord.SaveTrailer(DataStream);

            Resources.SaveObjects(DataStream, XRef);
        }
Beispiel #11
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, FontType());
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BaseFontName, GetFontName(Embed, Subset));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.EncodingName, EncodingType());
            long fc = FirstChar; if (fc < 0)

            {
                fc = 0;
            }

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FirstCharName, PdfConv.LongToString(fc));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LastCharName, PdfConv.LongToString(LastChar));

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

            SaveWidths(DataStream);

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

            SaveFontDescriptor(DataStream, FontDescriptorId, XRef, Embed, Subset);
        }
Beispiel #12
0
        public void WritePatternObject(TPdfStream DataStream, TXRefSection XRef)
        {
            int MatrixSize;

            byte[] PatternDef = GetPattern(out MatrixSize);

            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, "1");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PaintTypeName, "2");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TilingTypeName, "2");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, String.Format(CultureInfo.InvariantCulture, "[0 0 {0} {0}]", MatrixSize));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.XStepName, MatrixSize.ToString(CultureInfo.InvariantCulture));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.YStepName, MatrixSize.ToString(CultureInfo.InvariantCulture));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, PatternDef.Length);
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName));
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.EndDictionary(DataStream);

            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            DataStream.Write(PatternDef);
            TStreamRecord.EndSave(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);
        }
Beispiel #13
0
        private void SaveDocMDP(TPdfStream DataStream, TXRefSection XRef)
        {
            BeginDictionary(DataStream);
            SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.SigRefName));
            SaveKey(DataStream, TPdfToken.TransformMethodName, TPdfTokens.GetString(TPdfToken.DocMDPName));
            SaveTransformParams(DataStream);
            SaveKey(DataStream, TPdfToken.DigestMethodName, TPdfTokens.GetString(TPdfToken.MD5Name));

            //This is a small hack. We don't have an object model of the pdf file able to compute the object hash,
            //and it is not needed anyway for Acrobat >=7 (and <6 does not allow MDP anyway).
            //But we need to write something here, or acrobat will complain the document is not PDF/SigQ complaint.
            byte[] MDPHash    = new byte[16];
            string MDPHashStr = PdfConv.ToHexString(MDPHash, true);

            Write(DataStream, TPdfTokens.GetString(TPdfToken.DigestValueName));
            long StartMDPHash = DataStream.Position;

            Write(DataStream, MDPHashStr);
            string LocationString =
                TPdfTokens.GetString(TPdfToken.OpenArray) +
                String.Format(CultureInfo.InvariantCulture, "{0} {1}", StartMDPHash, MDPHashStr.Length) +
                TPdfTokens.GetString(TPdfToken.CloseArray);

            SaveKey(DataStream, TPdfToken.DigestLocationName, LocationString);

            EndDictionary(DataStream);
        }
Beispiel #14
0
 public void Select(TPdfStream DataStream)
 {
     TPdfBaseRecord.WriteLine(DataStream,
                              TPdfTokens.GetString(TPdfToken.PatternName) + " " + TPdfTokens.GetString(TPdfToken.Commandcs) + " " +
                              TPdfTokens.GetString(TPdfToken.GradientPrefix) + PatternId.ToString(CultureInfo.InvariantCulture) + " " +
                              TPdfTokens.GetString(TPdfToken.Commandscn));
 }
Beispiel #15
0
 protected override void SaveExtraKeys(TPdfStream DataStream, TXRefSection XRef, bool Compress)
 {
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.FunctionsName,
                               TPdfTokens.GetString(TPdfToken.OpenArray) + FunctionCalls(DataStream, XRef) + TPdfTokens.GetString(TPdfToken.CloseArray));
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.BoundsName, PdfConv.ToString(Bounds, true));
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.EncodeName, PdfConv.ToString(Encode, true));
 }
Beispiel #16
0
        private string GetRadialCoords()
        {
            StringBuilder Result = new StringBuilder();
            real          x0     = CenterPoint.X;
            real          y0     = CenterPoint.Y;

            PointF corner = Coords.Location;

            if (Math.Abs(CenterPoint.X - Coords.X) < Math.Abs(CenterPoint.X - Coords.Right))
            {
                corner.X = Coords.Right;
            }
            if (Math.Abs(CenterPoint.Y - Coords.Y) < Math.Abs(CenterPoint.Y - Coords.Bottom))
            {
                corner.Y = Coords.Bottom;
            }
            real r = (real)Math.Sqrt(Math.Pow(corner.X - CenterPoint.X, 2) + Math.Pow(corner.Y - CenterPoint.Y, 2));

            Result.Append(TPdfTokens.GetString(TPdfToken.OpenArray));
            Result.Append(PdfConv.CoordsToString(x0)); Result.Append(" ");
            Result.Append(PdfConv.CoordsToString(y0)); Result.Append(" ");
            Result.Append(PdfConv.CoordsToString(0)); Result.Append(" ");
            Result.Append(PdfConv.CoordsToString(x0)); Result.Append(" ");
            Result.Append(PdfConv.CoordsToString(y0)); Result.Append(" ");
            Result.Append(PdfConv.CoordsToString(r)); Result.Append(" ");
            Result.Append(TPdfTokens.GetString(TPdfToken.CloseArray));
            return(Result.ToString());
        }
Beispiel #17
0
        private void WriteShadingDictionary(TPdfStream DataStream, TXRefSection XRef)
        {
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ShadingName));
            TDictionaryRecord.BeginDictionary(DataStream);
            if (GradientType == TGradientType.Axial)
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.ShadingTypeName, "2");
            }
            else
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.ShadingTypeName, "3");
            }

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.ColorSpaceName, TPdfTokens.GetString(TPdfToken.DeviceRGBName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.ExtendName, TPdfTokens.GetString(TPdfToken.OpenArray) + "true true" + TPdfTokens.GetString(TPdfToken.CloseArray));

            if (GradientType == TGradientType.Axial)
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.CoordsName, GetCoords());
            }
            else
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.CoordsName, GetRadialCoords());
            }

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FunctionName, TIndirectRecord.GetCallObj(BlendFunction.GetFunctionObjId(DataStream, XRef)));
            TDictionaryRecord.EndDictionary(DataStream);
        }
Beispiel #18
0
        internal string GetDestStr(TPdfDestination Dest)
        {
            int PageId = PageTree.GetPageId(Dest.PageNumber);

            string PageStr = TIndirectRecord.GetCallObj(PageId);

            switch (Dest.ZoomOptions)
            {
            case TZoomOptions.Fit:
                return
                    (TPdfTokens.GetString(TPdfToken.OpenArray) +
                     PageStr + TPdfTokens.GetString(TPdfToken.FitName) +
                     TPdfTokens.GetString(TPdfToken.CloseArray));

            case TZoomOptions.FitH:
                return
                    (TPdfTokens.GetString(TPdfToken.OpenArray) +
                     PageStr + TPdfTokens.GetString(TPdfToken.FitHName) +
                     TPdfTokens.GetString(TPdfToken.CloseArray));

            case TZoomOptions.FitV:
                return
                    (TPdfTokens.GetString(TPdfToken.OpenArray) +
                     PageStr + TPdfTokens.GetString(TPdfToken.FitVName) +
                     TPdfTokens.GetString(TPdfToken.CloseArray));
            }
            return
                (TPdfTokens.GetString(TPdfToken.OpenArray) +
                 PageStr + TPdfTokens.GetString(TPdfToken.XYZName) +
                 TPdfTokens.GetString(TPdfToken.CloseArray));
        }
Beispiel #19
0
        internal TPdfStream(Stream aDataStream, TPdfSignature aSignature)
        {
            EndTextData = TPdfBaseRecord.Coder.GetBytes(TPdfTokens.GetString(TPdfToken.CommandEndText) + TPdfTokens.NewLine);

            Signature = aSignature;
            if (Signature != null)
            {
                if (Signature.SignerFactory != null)
                {
                    Signer = Signature.SignerFactory.CreateSigner();
                }
                else
                {
                    PdfMessages.ThrowException(PdfErr.ErrUnassingedSignerFactory);
                }
            }

            if (Signer == null)
            {
                FDataStream = aDataStream;
            }
            else
            {
                FDataStream = new TSignedStream(aDataStream, Signer);                                                  //When signing we use a special stream that will compute the hash.
            }
            SignedStream = FDataStream as TSignedStream;
        }
Beispiel #20
0
        public void WritePatternObject(TPdfStream DataStream, TXRefSection XRef)
        {
            byte[] PatternDef = GetPatternDef();
            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, "1");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PaintTypeName, "1");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TilingTypeName, "2");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, String.Format(CultureInfo.InvariantCulture, "[0 0 {0} {1}]", ImgWidth, ImgHeight));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.XStepName, PdfConv.CoordsToString(ImgWidth));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.YStepName, PdfConv.CoordsToString(ImgHeight));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.MatrixName, PdfConv.ToString(PatternMatrix, true));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, PatternDef.Length);
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName));

            TDictionaryRecord.BeginDictionary(DataStream);
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.XObjectName));
            TDictionaryRecord.BeginDictionary(DataStream);

            ImageDef.WriteImage(DataStream, XRef);
            TDictionaryRecord.EndDictionary(DataStream);
            TDictionaryRecord.EndDictionary(DataStream);
            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            DataStream.Write(PatternDef);
            TStreamRecord.EndSave(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);

            ImageDef.WriteImageObject(DataStream, XRef);
        }
Beispiel #21
0
        public void WriteGStateObject(TPdfStream DataStream, TXRefSection XRef)
        {
            XRef.SetObjectOffset(GStateObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, GStateObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.ExtGStateName));
            TDictionaryRecord.SaveKey(DataStream, Operator, PdfConv.CoordsToString(Alpha / 255.0));

            if (SMask != null)
            {
                SMaskObjId = XRef.GetNewObject(DataStream);
                TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.SMaskName));
                TDictionaryRecord.BeginDictionary(DataStream);
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.MaskName));
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.SName, TPdfTokens.GetString(TPdfToken.AlphaName));
                TDictionaryRecord.Write(DataStream, TPdfTokens.GetString(TPdfToken.GName) + " ");
                TIndirectRecord.CallObj(DataStream, SMaskObjId);
                TDictionaryRecord.EndDictionary(DataStream);
            }

            TDictionaryRecord.EndDictionary(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);

            if (SMask != null)
            {
                WriteSMaskObject(DataStream, XRef);
            }
        }
Beispiel #22
0
 private static void SaveResourcesFirstXObject(TPdfStream DataStream, TXRefSection XRef, int FRMId)
 {
     Write(DataStream, TPdfTokens.GetString(TPdfToken.XObjectName));
     BeginDictionary(DataStream);
     SaveKey(DataStream, TPdfToken.FRMName, TIndirectRecord.GetCallObj(FRMId));
     EndDictionary(DataStream);
     EndDictionary(DataStream);
 }
Beispiel #23
0
 private void SaveReferenceDict(TPdfStream DataStream, TXRefSection XRef)
 {
     Write(DataStream, TPdfTokens.GetString(TPdfToken.ReferenceName));
     Write(DataStream, TPdfTokens.GetString(TPdfToken.OpenArray));
     SaveDocMDP(DataStream, XRef);
     SaveFieldMDP(DataStream, XRef);
     Write(DataStream, TPdfTokens.GetString(TPdfToken.CloseArray));
 }
Beispiel #24
0
        public static int WriteColorSpace(TPdfStream DataStream, TXRefSection XRef)
        {
            int Result = XRef.GetNewObject(DataStream);

            TPdfBaseRecord.Write(DataStream, TPdfTokens.GetString(TPdfToken.PatternColorSpacePrefix) + " ");
            TIndirectRecord.CallObj(DataStream, Result);

            return(Result);
        }
Beispiel #25
0
 public static void WriteColorSpaceObject(TPdfStream DataStream, TXRefSection XRef, int ColorSpaceId)
 {
     XRef.SetObjectOffset(ColorSpaceId, DataStream);
     TIndirectRecord.SaveHeader(DataStream, ColorSpaceId);
     TPdfBaseRecord.Write(DataStream, TPdfTokens.GetString(TPdfToken.OpenArray));
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.PatternName, TPdfTokens.GetString(TPdfToken.DeviceRGBName));
     TPdfBaseRecord.Write(DataStream, TPdfTokens.GetString(TPdfToken.CloseArray));
     TIndirectRecord.SaveTrailer(DataStream);
 }
Beispiel #26
0
 private void SaveTransformParams(TPdfStream DataStream)
 {
     Write(DataStream, TPdfTokens.GetString(TPdfToken.TransformParamsName));
     BeginDictionary(DataStream);
     SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.TransformParamsName));
     SaveKey(DataStream, TPdfToken.PName, Signature.AllowedChangesValue);
     SaveKey(DataStream, TPdfToken.VName, TPdfTokens.GetString(TPdfToken.V1_2Name));
     EndDictionary(DataStream);
 }
Beispiel #27
0
 private void SaveKids(TPdfStream DataStream, TXRefSection XRef)
 {
     WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.KidsName) + " " + TPdfTokens.GetString(TPdfToken.OpenArray));
     for (int i = 0; i < FList.Count; i++)
     {
         TIndirectRecord.CallObj(DataStream, FList[i].Id);
     }
     WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.CloseArray));
 }
Beispiel #28
0
 private static void WriteCommonXObject(TPdfStream DataStream, RectangleF Rect, string StreamContents)
 {
     SaveKey(DataStream, TPdfToken.LengthName, StreamContents.Length);
     SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.XObjectName));
     SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.FormName));
     SaveKey(DataStream, TPdfToken.FormTypeName, 1);
     SaveKey(DataStream, TPdfToken.MatrixName, "[1.0 0.0 0.0 1.0 0.0 0.0]"); //Standard drawing matrix
     SaveKey(DataStream, TPdfToken.BBoxName, PdfConv.ToRectangleWH(new RectangleF(0, 0, Rect.Width, Rect.Height), true));
 }
Beispiel #29
0
 private static void SaveResourcesSecondXObject(TPdfStream DataStream, int n0Id, int n2Id)
 {
     Write(DataStream, TPdfTokens.GetString(TPdfToken.XObjectName));
     BeginDictionary(DataStream);
     SaveKey(DataStream, TPdfToken.n0Name, TIndirectRecord.GetCallObj(n0Id));
     SaveKey(DataStream, TPdfToken.n2Name, TIndirectRecord.GetCallObj(n2Id));
     EndDictionary(DataStream);
     EndDictionary(DataStream);
 }
Beispiel #30
0
        internal override void SaveToStream(TPdfStream DataStream, TXRefSection XRef)
        {
            BeginSaveToStream(DataStream, XRef);
            SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.LinkName));
            SaveKey(DataStream, TPdfToken.AName, TIndirectRecord.GetCallObj(ActionId));
            SaveKey(DataStream, TPdfToken.BorderName, TPdfTokens.GetString(TPdfToken.Border0));
            EndSaveToStream(DataStream, XRef);

            SaveAction(DataStream, XRef);
        }