Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
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.º 9
0
        public static string ToString(float[] 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.CoordsToString(Source[i]));
                if (i < Source.Length - 1)
                {
                    Result.Append(" ");
                }
            }
            if (AddBrackets)
            {
                Result.Append(TPdfTokens.GetString(TPdfToken.CloseArray));
            }
            return(Result.ToString());
        }