Example #1
0
        /// <summary>
        /// Writes PDF path into file stream
        /// </summary>
        /// <param name="path">PDF path element</param>
        internal void Write(PathElement path)
        {
            var x = TextAdapter.FormatFloat(path.X);
              var y = TextAdapter.FormatFloat(path.Y);

              var pathCoordinates = new List<string> { PATH_START_FORMAT.Args(x, y) };
              pathCoordinates.AddRange(path.Primitives.Select(p => p.ToPdfString()));

              var closeTag = path.IsClosed ? "B" : "S";

              var pathContent = new StringBuilder();
              pathContent.AppendLine("q");
              pathContent.Append(path.Style.ToPdfString());
              pathContent.AppendFormatLine(string.Join(Constants.SPACE, pathCoordinates));
              pathContent.AppendLine(closeTag);
              pathContent.Append("Q");

              writeStreamedObject(path.ObjectId, pathContent.ToString());
        }
Example #2
0
        /// <summary>
        /// Add line primitive to the page
        /// </summary>
        public PathElement AddLine(float x1, float y1, float x2, float y2, PdfDrawStyle style)
        {
            var path = new PathElement(x1, y1, style);
              path.AddLine(x2, y2);
              Add(path);

              return path;
        }
Example #3
0
        /// <summary>
        /// Add path to the page
        /// </summary>
        public PathElement AddPath(float x, float y, PdfDrawStyle style)
        {
            var path = new PathElement(x, y, style);
              Add(path);

              return path;
        }
Example #4
0
        /// <summary>
        /// Add circle primitive to the page
        /// </summary>
        public PathElement AddCircle(float centerX, float centerY, float r, PdfDrawStyle borderStyle)
        {
            var path = new PathElement(centerX - r, centerY, borderStyle);
              path.IsClosed = true;
              path.AddBezier(centerX - r, centerY + Constants.SQRT_TWO * r, centerX + r, centerY + Constants.SQRT_TWO * r, centerX + r, centerY);
              path.AddBezier(centerX + r, centerY - Constants.SQRT_TWO * r, centerX - r, centerY - Constants.SQRT_TWO * r, centerX - r, centerY);
              Add(path);

              return path;
        }