Esempio n. 1
0
 public PdfText(string value, PdfFont font, PdfMeasurement fontSize, PdfPoint location, PdfStreamState state = default(PdfStreamState))
 {
     Value    = value;
     Font     = font;
     FontSize = fontSize;
     Location = location;
     State    = state;
 }
Esempio n. 2
0
        private IEnumerable <PdfPathCommand> GetCommands(double theta, double startAngle)
        {
            if (theta <= 0.0)
            {
                yield break;
            }

            // from http://www.tinaja.com/glib/bezcirc2.pdf
            var x0 = Math.Cos(theta * 0.5);
            var y0 = -Math.Sin(theta * 0.5);

            var x3 = x0;
            var y3 = -y0;

            var x1 = (4.0 - x0) / 3.0;
            var y1 = ((1.0 - x0) * (3.0 - x0)) / (3.0 * y0);

            var x2 = x1;
            var y2 = -y1;

            var p0 = new PdfPoint(PdfMeasurement.Points(x0), PdfMeasurement.Points(y0));
            var p1 = new PdfPoint(PdfMeasurement.Points(x1), PdfMeasurement.Points(y1));
            var p2 = new PdfPoint(PdfMeasurement.Points(x2), PdfMeasurement.Points(y2));
            var p3 = new PdfPoint(PdfMeasurement.Points(x3), PdfMeasurement.Points(y3));

            // now rotate points by (theta / 2) + startAngle
            var rotTheta = theta * 0.5 + startAngle;

            p0 = p0.RotateAboutOrigin(rotTheta);
            p1 = p1.RotateAboutOrigin(rotTheta);
            p2 = p2.RotateAboutOrigin(rotTheta);
            p3 = p3.RotateAboutOrigin(rotTheta);

            // multiply by the radius
            p0 = new PdfPoint(p0.X * RadiusX, p0.Y * RadiusY);
            p1 = new PdfPoint(p1.X * RadiusX, p1.Y * RadiusY);
            p2 = new PdfPoint(p2.X * RadiusX, p2.Y * RadiusY);
            p3 = new PdfPoint(p3.X * RadiusX, p3.Y * RadiusY);

            // do final rotation
            p0 = p0.RotateAboutOrigin(RotationAngle);
            p1 = p1.RotateAboutOrigin(RotationAngle);
            p2 = p2.RotateAboutOrigin(RotationAngle);
            p3 = p3.RotateAboutOrigin(RotationAngle);

            // offset for the center
            p0 += Center;
            p1 += Center;
            p2 += Center;
            p3 += Center;

            yield return(new PdfPathMoveTo(p0));

            yield return(new PdfCubicBezier(p1, p2, p3));
        }
Esempio n. 3
0
        public PdfEllipse(PdfPoint center, PdfMeasurement radiusX, PdfMeasurement radiusY, double rotationAngle = 0.0, double startAngle = 0.0, double endAngle = Math.PI * 2.0, PdfStreamState state = default(PdfStreamState))
        {
            Center        = center;
            RadiusX       = radiusX;
            RadiusY       = radiusY;
            RotationAngle = rotationAngle;
            StartAngle    = startAngle;
            EndAngle      = endAngle;
            State         = state;

            while (StartAngle < 0.0)
            {
                StartAngle += Math.PI * 2.0;
            }

            while (EndAngle < 0.0)
            {
                EndAngle += Math.PI * 2.0;
            }
        }
Esempio n. 4
0
        public static PdfPage NewASeries(int n, bool isPortrait = true)
        {
            var longSide  = (int)(1000.0 / Math.Pow(2.0, (2.0 * n - 1.0) / 4.0) + 0.2);
            var shortSide = (int)(longSide / Math.Sqrt(2.0));

            switch (n)
            {
            case 0:
            case 3:
            case 6:
                // manually correct rounding errors
                shortSide++;
                break;
            }

            var width  = isPortrait ? shortSide : longSide;
            var height = isPortrait ? longSide : shortSide;

            return(new PdfPage(PdfMeasurement.Mm(width), PdfMeasurement.Mm(height)));
        }
Esempio n. 5
0
 private void WriteStrokeWidth(PdfMeasurement strokeWidth)
 {
     WriteLine($"{strokeWidth.AsPoints().AsInvariant()} w");
 }
Esempio n. 6
0
 public static PdfPage NewLetterLandscape()
 {
     return(new PdfPage(PdfMeasurement.Inches(LetterHeight), PdfMeasurement.Inches(LetterWidth)));
 }
Esempio n. 7
0
 public PdfPage(PdfMeasurement width, PdfMeasurement height, params IPdfEncoder[] encoders)
 {
     Width  = width;
     Height = height;
     Stream = new PdfStream(encoders);
 }
Esempio n. 8
0
 public PdfPoint(PdfMeasurement x, PdfMeasurement y)
 {
     X = x;
     Y = y;
 }