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); }
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); }
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); } }
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); }
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()); }
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)); }
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)); }
private string GetCoords() { StringBuilder Result = new StringBuilder(); Result.Append(TPdfTokens.GetString(TPdfToken.OpenArray)); Result.Append(PdfConv.CoordsToString(RotatedCoords.Left)); Result.Append(" "); Result.Append(PdfConv.CoordsToString(RotatedCoords.Top)); Result.Append(" "); Result.Append(PdfConv.CoordsToString(RotatedCoords.Right)); Result.Append(" "); Result.Append(PdfConv.CoordsToString(RotatedCoords.Bottom)); Result.Append(TPdfTokens.GetString(TPdfToken.CloseArray)); return(Result.ToString()); }
protected override void SaveExtraKeys(TPdfStream DataStream, TXRefSection XRef, bool Compress) { Debug.Assert(DataStream.Compress == false); //It shouldn't be turned on at this place. TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, FunctionData(Compress).Length.ToString(CultureInfo.InvariantCulture)); if (NeedsCompression(Compress)) { TStreamRecord.SetFlateDecode(DataStream); } TDictionaryRecord.SaveKey(DataStream, TPdfToken.SizeName, PdfConv.ToString(Size, true)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.BitsPerSampleName, 8); }
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); }
internal string GetSMask() { StringBuilder Result = new StringBuilder(); Result.Append(TPdfTokens.GetString(TPdfToken.PatternName)); Result.Append(" "); Result.Append(TPdfTokens.GetString(TPdfToken.Commandcs)); Result.Append(" "); Result.Append(TPdfTokens.GetString(TPdfToken.GradientPrefix)); Result.Append(Convert.ToString(PatternId, CultureInfo.InvariantCulture)); Result.Append(" "); Result.Append(TPdfTokens.GetString(TPdfToken.Commandscn)); Result.Append(" "); Result.Append(PdfConv.ToRectangleWH(Coords, false)); Result.Append(" "); Result.Append(TPdfTokens.GetString(TPdfToken.CommandRectangle)); Result.Append(" "); Result.Append(TPdfTokens.GetString(TPdfToken.CommandFillPath)); return(Result.ToString()); }
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)); }
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); }
internal void GoReal(byte[] AfterSign, int PKCSSize) { Debug.Assert(HelperStream != null); Signer.Write(AfterSign, 0, AfterSign.Length); if (PKCSSize + AfterSign.Length > SignOffset) { PdfMessages.ThrowException(PdfErr.ErrSigningLengthToSmall); } byte[] PaddedByteCount = Pad(0x20, SignOffset - (PKCSSize + AfterSign.Length)); Signer.Write(PaddedByteCount, 0, PaddedByteCount.Length); byte[] bt = HelperStream.CurrentStream.ToArray(); HelperStream.Dispose(); HelperStream = null; Signer.Write(bt, 0, bt.Length); byte[] sg = Signer.GetSignature(); byte[] hexsg = TPdfBaseRecord.Coder.GetBytes("<" + PdfConv.ToHexString(sg, false)); FDataStream.Write(hexsg, 0, hexsg.Length); if (hexsg.Length > PKCSSize - 1) { PdfMessages.ThrowException(PdfErr.ErrSigningLengthToSmall); } for (int i = hexsg.Length; i < PKCSSize - 1; i++) //pad the certificate. { FDataStream.WriteByte(0); } FDataStream.Write(TPdfBaseRecord.Coder.GetBytes(">"), 0, 1); FDataStream.Write(AfterSign, 0, AfterSign.Length); FDataStream.Write(PaddedByteCount, 0, PaddedByteCount.Length); //Pad the whole thing. FDataStream.Write(bt, 0, bt.Length); }
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); }
public static string ToString(int[] Source, bool AddBrackets) { StringBuilder Result = new StringBuilder(); if (AddBrackets) { Result.Append(TPdfTokens.GetString(TPdfToken.OpenArray)); } for (int i = 0; i < Source.Length; i++) { Result.Append(PdfConv.LongToString(Source[i])); if (i < Source.Length - 1) { Result.Append(" "); } } if (AddBrackets) { Result.Append(TPdfTokens.GetString(TPdfToken.CloseArray)); } return(Result.ToString()); }
internal static void SaveToStream(TPdfStream DataStream, TXRefSection XRef, int CatalogId, int InfoId) { TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.Trailer)); TDictionaryRecord.BeginDictionary(DataStream); TDictionaryRecord.SaveKey(DataStream, TPdfToken.SizeName, XRef.Count); TDictionaryRecord.SaveKey(DataStream, TPdfToken.RootName, TIndirectRecord.GetCallObj(CatalogId)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.InfoName, TIndirectRecord.GetCallObj(InfoId)); Byte[] FileIdBytes = Guid.NewGuid().ToByteArray(); string FileId = PdfConv.ToHexString(FileIdBytes, true); TDictionaryRecord.SaveKey(DataStream, TPdfToken.IDName, TPdfTokens.GetString(TPdfToken.OpenArray) + FileId + " " + FileId + TPdfTokens.GetString(TPdfToken.CloseArray)); TDictionaryRecord.EndDictionary(DataStream); TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.StartXRef)); TPdfBaseRecord.WriteLine(DataStream, XRef.StartPosition.ToString(CultureInfo.InvariantCulture)); TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.Eof)); }
public void WriteFunctionObject(TPdfStream DataStream, TXRefSection XRef, bool Compress) { XRef.SetObjectOffset(GetFunctionObjId(DataStream, XRef), DataStream); TIndirectRecord.SaveHeader(DataStream, FunctionObjId); TDictionaryRecord.BeginDictionary(DataStream); TDictionaryRecord.SaveKey(DataStream, TPdfToken.FunctionTypeName, FunctionType); if (Domain != null) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.DomainName, PdfConv.ToString(Domain, true)); } if (Range != null) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.RangeName, PdfConv.ToString(Range, true)); } SaveExtraKeys(DataStream, XRef, Compress); TDictionaryRecord.EndDictionary(DataStream); SaveStream(DataStream, XRef, Compress); TIndirectRecord.SaveTrailer(DataStream); }
public static void SaveKey(TPdfStream DataStream, TPdfToken Tk, int Value) { SaveKey(DataStream, Tk, PdfConv.LongToString(Value)); }
internal void SaveBookmarkObjects(TPdfStream DataStream, TXRefSection XRef, TBookmarkList bmks, int ParentId, int ObjectId, ref int FirstId, ref int LastId, ref int AllOpenCount) { int PreviousId = -1; for (int i = 0; i < bmks.Count; i++) { TBookmark b = bmks[i]; AllOpenCount++; int NextId = -1; if (i < bmks.Count - 1) { NextId = XRef.GetNewObject(DataStream); } LastId = ObjectId; if (FirstId == -1) { FirstId = ObjectId; } int FirstChildId = -1; int LastChildId = -1; int ChildOpenCount = 0; if (b.FChildren.Count > 0) { FirstChildId = XRef.GetNewObject(DataStream); int ChildLastId = -1; SaveBookmarkObjects(DataStream, XRef, b.FChildren, ObjectId, FirstChildId, ref FirstId, ref ChildLastId, ref ChildOpenCount); if (!b.ChildrenCollapsed) { AllOpenCount += ChildOpenCount; } LastChildId = ChildLastId; } XRef.SetObjectOffset(ObjectId, DataStream); TIndirectRecord.SaveHeader(DataStream, ObjectId); TDictionaryRecord.BeginDictionary(DataStream); TDictionaryRecord.SaveUnicodeKey(DataStream, TPdfToken.TitleName, b.Title); TDictionaryRecord.SaveKey(DataStream, TPdfToken.ParentName, TIndirectRecord.GetCallObj(ParentId)); if (PreviousId >= 0) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.PrevName, TIndirectRecord.GetCallObj(PreviousId)); } if (NextId >= 0) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.NextName, TIndirectRecord.GetCallObj(NextId)); } if (FirstChildId >= 0) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.FirstName, TIndirectRecord.GetCallObj(FirstChildId)); } if (LastChildId >= 0) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.LastName, TIndirectRecord.GetCallObj(LastChildId)); } if (ChildOpenCount > 0) { if (b.ChildrenCollapsed) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.CountName, -ChildOpenCount); } else { TDictionaryRecord.SaveKey(DataStream, TPdfToken.CountName, ChildOpenCount); } } if (b.Destination != null) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.DestName, GetDestStr(b.Destination)); } if (b.TextColor.R != 0 || b.TextColor.G != 0 || b.TextColor.B != 0) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.CName, TPdfTokens.GetString(TPdfToken.OpenArray) + PdfConv.ToString(b.TextColor) + TPdfTokens.GetString(TPdfToken.CloseArray)); } if (b.TextStyle != TBookmarkStyle.None) { int k = 0; if ((b.TextStyle & TBookmarkStyle.Italic) != 0) { k |= 1; } if ((b.TextStyle & TBookmarkStyle.Bold) != 0) { k |= 2; } TDictionaryRecord.SaveKey(DataStream, TPdfToken.FName, k); } TDictionaryRecord.EndDictionary(DataStream); TIndirectRecord.SaveTrailer(DataStream); PreviousId = ObjectId; ObjectId = NextId; } }
internal void SelectBrush(TPdfStream DataStream, PathGradientBrush aBrush, RectangleF Rect, RectangleF RotatedCoords, PointF CenterPoint, string DrawingMatrix) { ColorBlend cb = null; try { cb = aBrush.InterpolationColors; } catch (ArgumentException)//Awful way to tell if it has InterpolationColors, but the framework does not give us a choice. { } if (cb == null || cb.Colors.Length == 1) { cb = GetColorBlendWithoutInterpolationColors(aBrush.Blend, aBrush.SurroundColors[0], aBrush.CenterColor); } int n = cb.Colors.Length - 1; if (cb.Colors[0].A != 255 || cb.Colors[n].A != 255) { ColorBlend TransparencyBlend = new ColorBlend(2); TransparencyBlend.Colors[0] = ColorUtil.FromArgb(cb.Colors[0].A, cb.Colors[0].A, cb.Colors[0].A); TransparencyBlend.Positions[0] = 0; TransparencyBlend.Colors[1] = ColorUtil.FromArgb(cb.Colors[n].A, cb.Colors[n].A, cb.Colors[n].A); TransparencyBlend.Positions[1] = 1; TPdfGradient SMask = Resources.GetGradient(TGradientType.Radial, TransparencyBlend, Rect, aBrush.CenterPoint, RotatedCoords, DrawingMatrix); SelectTransparency(DataStream, 255, TPdfToken.CommandSetAlphaBrush, SMask.GetSMask(), PdfConv.ToRectangleXY(Rect, true)); } Resources.SelectGradient(DataStream, TGradientType.Radial, cb, Rect, CenterPoint, RotatedCoords, DrawingMatrix); }
internal void SelectBrush(TPdfStream DataStream, LinearGradientBrush aBrush, RectangleF Rect, RectangleF RotatedCoords, string DrawingMatrix) { #if (WPF) ColorBlend cb = aBrush.GradientStops; #else ColorBlend cb = null; try { if (aBrush.Blend == null) { cb = aBrush.InterpolationColors; //if it has interpolationcolors, blend must be null. } } catch (ArgumentException) //Awful way to tell if it has Interpolationcolors, but the framework does not give us a choice. { } if (cb == null) { cb = GetColorBlendWithoutInterpolationColors(aBrush.Blend, aBrush.LinearColors[0], aBrush.LinearColors[1]); } #endif int n = cb.Colors.Length - 1; if (cb.Colors[0].A != 255 || cb.Colors[n].A != 255) { ColorBlend TransparencyBlend = new ColorBlend(2); TransparencyBlend.Colors[0] = ColorUtil.FromArgb(cb.Colors[0].A, cb.Colors[0].A, cb.Colors[0].A); TransparencyBlend.Positions[0] = 0; TransparencyBlend.Colors[1] = ColorUtil.FromArgb(cb.Colors[n].A, cb.Colors[n].A, cb.Colors[n].A); TransparencyBlend.Positions[1] = 1; TPdfGradient SMask = Resources.GetGradient(TGradientType.Axial, TransparencyBlend, Rect, Rect.Location, RotatedCoords, DrawingMatrix); SelectTransparency(DataStream, 255, TPdfToken.CommandSetAlphaBrush, SMask.GetSMask(), PdfConv.ToRectangleXY(Rect, true)); } Resources.SelectGradient(DataStream, TGradientType.Axial, cb, Rect, Rect.Location, RotatedCoords, DrawingMatrix); }
protected override void SaveExtraKeys(TPdfStream DataStream, TXRefSection XRef, bool Compress) { TDictionaryRecord.SaveKey(DataStream, TPdfToken.C0Name, PdfConv.ToString(C0, true)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.C1Name, PdfConv.ToString(C1, true)); TDictionaryRecord.SaveKey(DataStream, TPdfToken.NName, PdfConv.DoubleToString(N)); }