コード例 #1
0
        public void DrawLine_Colors()
        {
            var doc = new PortableDocument();

            doc.AddPage(100, 100);
            double x  = 0;
            double y0 = 78;
            double y1 = 10;

            doc.DrawLine(10, 95, 10, 80);

            doc.SetColor(0, 0, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(1, 1, 1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(1, 0, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(0, 1, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(0, 0, 1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(1, 1, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.Save(Folder + "DrawLine_Colors.pdf");
        }
コード例 #2
0
        public void DrawLine_LineWidths()
        {
            var doc = new PortableDocument();

            doc.AddPage(100, 100);
            double x  = 0;
            double y0 = 78;
            double y1 = 10;

            doc.DrawLine(20, 95, 20, 80);

            doc.SetLineWidth(0.1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetLineWidth(1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetLineWidth(2);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetLineWidth(3);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.Save(Folder + "DrawLine_LineWidths.pdf");
        }
コード例 #3
0
        public void DrawLine_LineDashPatterns()
        {
            var doc = new PortableDocument();

            doc.AddPage(100, 100);
            double x0 = 10;
            double x1 = 40;
            double y  = 100;
            double dy = -5;

            doc.SetLineWidth(1);

            // default dash pattern
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new double[] { }, 0);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 3d }, 0);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 2d }, 1);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 2d, 1 }, 0);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 3d, 5 }, 6);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 2d, 3 }, 11);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.Save(Folder + "DrawLine_LineDashPatterns.pdf");
        }
コード例 #4
0
        public void Stroke_LineJoins()
        {
            var doc = new PortableDocument();

            doc.AddPage(100, 100);

            doc.SetLineWidth(3);
            doc.MoveTo(10, 10);
            doc.LineTo(50, 60);
            doc.LineTo(90, 10);
            doc.Stroke(false);

            doc.SetColor(1, 0, 0);
            doc.SetLineJoin(LineJoin.Bevel);
            doc.MoveTo(10, 20);
            doc.LineTo(50, 70);
            doc.LineTo(90, 20);
            doc.Stroke(false);

            doc.SetColor(0, 1, 0);
            doc.SetLineJoin(LineJoin.Miter);
            doc.MoveTo(10, 30);
            doc.LineTo(50, 80);
            doc.LineTo(90, 30);
            doc.Stroke(false);

            doc.SetColor(0, 0, 1);
            doc.SetLineJoin(LineJoin.Round);
            doc.MoveTo(10, 40);
            doc.LineTo(50, 90);
            doc.LineTo(90, 40);
            doc.Stroke(false);

            doc.Save(Folder + "Stroke_LineJoins.pdf");
        }
コード例 #5
0
        public void AddPage_EmptyDocument()
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);
            doc.Save(Folder + "EmptyDocument.pdf");
        }
コード例 #6
0
        public void DrawPolygon()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);

            doc.MoveTo(50, 30);
            doc.LineTo(170, 30);
            doc.LineTo(100, 70);
            doc.SetColor(OxyColors.Orange);
            doc.SetFillColor(OxyColors.LightGreen);
            doc.FillAndStroke();

            doc.MoveTo(5, 5);
            doc.LineTo(5, 25);
            doc.LineTo(25, 5);
            doc.Fill();

            doc.MoveTo(195, 95);
            doc.LineTo(175, 95);
            doc.LineTo(195, 75);
            doc.Stroke();

            doc.Save(Folder + "DrawPolygon.pdf");
        }
コード例 #7
0
 public void DrawText_HelloWorld()
 {
     var doc = new PortableDocument();
     doc.AddPage(PageSize.A4);
     doc.SetFont("Arial", 96);
     doc.DrawText(50, 400, "Hello world!");
     doc.Save(Folder + "DrawText.pdf");
 }
コード例 #8
0
        public void DrawLine()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);
            doc.DrawLine(50, 50, 100, 70);
            doc.Save(Folder + "DrawLine.pdf");
        }
コード例 #9
0
        public void DrawText_HelloWorld()
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);
            doc.SetFont("Arial", 96);
            doc.DrawText(50, 400, "Hello world!");
            doc.Save(Folder + "DrawText.pdf");
        }
コード例 #10
0
        public void DrawImage()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);
            //// var image = new PortableDocument.Image() { };
            //// doc.DrawImage(image);
            doc.Save(Folder + "DrawImage.pdf");
        }
コード例 #11
0
        public void FillCircle()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 200);
            doc.SetColor(OxyColors.Blue);
            doc.SetFillColor(OxyColors.LightBlue);
            doc.FillCircle(100, 100, 95);
            doc.Save(Folder + "FillCircle.pdf");
        }
コード例 #12
0
        public void FillEllipse()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);
            doc.SetColor(OxyColors.Orange);
            doc.SetFillColor(OxyColors.LightGreen);
            doc.FillEllipse(5, 5, 190, 90);
            doc.Save(Folder + "FillEllipse.pdf");
        }
コード例 #13
0
 public void DrawText_SpecialCharacters()
 {
     var doc = new PortableDocument();
     doc.AddPage(PageSize.A4);
     doc.SetFont("Arial", 96);
     var s = "π";
     doc.DrawText(50, 400, s);
     doc.Save(Folder + "DrawText_SpecialCharacters.pdf");
     Assert.IsTrue(s[0] > 255);
 }
コード例 #14
0
        public void FillRectangle()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);
            doc.SetColor(OxyColors.Gainsboro);
            doc.SetFillColor(OxyColors.Navy);
            doc.FillRectangle(5, 5, 100, 70);
            doc.Save(Folder + "FillRectangle.pdf");
        }
コード例 #15
0
        public void DrawEllipse()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);
            doc.SetColor(OxyColors.Orange);
            doc.SetFillColor(OxyColors.LightGreen);
            doc.DrawEllipse(5, 5, 190, 90, true);
            doc.DrawEllipse(175, 85, 20, 10);
            doc.Save(Folder + "DrawEllipse.pdf");
        }
コード例 #16
0
        public void DrawRectangle()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 100);
            doc.SetColor(OxyColors.Navy);
            doc.SetFillColor(OxyColors.Gainsboro);
            doc.DrawRectangle(5, 5, 100, 70, true);
            doc.DrawRectangle(185, 85, 10, 10);
            doc.Save(Folder + "DrawRectangle.pdf");
        }
コード例 #17
0
        public void DrawText_SpecialCharacters()
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);
            doc.SetFont("Arial", 96);
            var s = "π";

            doc.DrawText(50, 400, s);
            doc.Save(Folder + "DrawText_SpecialCharacters.pdf");
            Assert.IsTrue(s[0] > 255);
        }
コード例 #18
0
        public void Stroke_LineCaps()
        {
            var doc = new PortableDocument();

            doc.AddPage(100, 100);

            doc.SetColor(0.5, 0.5, 0.5);
            doc.SetLineWidth(3);
            doc.MoveTo(10, 10);
            doc.LineTo(50, 60);
            doc.LineTo(90, 10);
            doc.Stroke(false);

            doc.SetColor(1, 0, 0);
            doc.SetLineCap(LineCap.Butt);
            doc.MoveTo(10, 20);
            doc.LineTo(50, 70);
            doc.LineTo(90, 20);
            doc.Stroke(false);

            doc.SetColor(0, 1, 0);
            doc.SetLineCap(LineCap.ProjectingSquare);
            doc.MoveTo(10, 30);
            doc.LineTo(50, 80);
            doc.LineTo(90, 30);
            doc.Stroke(false);

            doc.SetColor(0, 0, 1);
            doc.SetLineCap(LineCap.Round);
            doc.MoveTo(10, 40);
            doc.LineTo(50, 90);
            doc.LineTo(90, 40);
            doc.Stroke(false);

            doc.SetColor(0, 0, 0);
            doc.SetLineWidth(0.1);
            doc.MoveTo(10, 10);
            doc.LineTo(50, 60);
            doc.LineTo(90, 10);
            doc.MoveTo(10, 20);
            doc.LineTo(50, 70);
            doc.LineTo(90, 20);
            doc.MoveTo(10, 30);
            doc.LineTo(50, 80);
            doc.LineTo(90, 30);
            doc.MoveTo(10, 40);
            doc.LineTo(50, 90);
            doc.LineTo(90, 40);
            doc.Stroke(false);

            doc.Save(Folder + "Stroke_LineCaps.pdf");
        }
コード例 #19
0
        public void SetClippingRectangle()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 200);
            doc.SetColor(OxyColors.Blue);
            doc.SetFillColor(OxyColors.LightBlue);
            doc.SaveState();
            doc.SetClippingRectangle(5, 5, 50, 50);
            doc.DrawCircle(100, 100, 95, true);
            doc.RestoreState();
            doc.DrawCircle(120, 120, 70);
            doc.Save(Folder + "SetClippingRectangle.pdf");
        }
コード例 #20
0
 public void AddProperties_EmptyDocument()
 {
     var doc = new PortableDocument
     {
         Title = "The title",
         Author = "the author",
         Subject = "the subject",
         Keywords = "key;words",
         Creator = "the creator",
         Producer = "the producer"
     };
     doc.AddPage(PageSize.A4);
     doc.Save(Folder + "Properties.pdf");
 }
コード例 #21
0
        public void Transparency()
        {
            var doc = new PortableDocument();

            doc.AddPage(220, 100);
            doc.SetFillColor(OxyColors.Black);
            doc.FillRectangle(0, 45, 220, 10);
            for (int i = 0; i <= 10; i++)
            {
                doc.SetFillColor(OxyColor.FromAColor((byte)(255d * i / 10), OxyColors.Gold));
                doc.FillEllipse((i * 20) + 1, 41, 18, 18);
            }

            doc.Save(Folder + "Transparency.pdf");
        }
コード例 #22
0
        public void AddProperties_EmptyDocument()
        {
            var doc = new PortableDocument
            {
                Title    = "The title",
                Author   = "the author",
                Subject  = "the subject",
                Keywords = "key;words",
                Creator  = "the creator",
                Producer = "the producer"
            };

            doc.AddPage(PageSize.A4);
            doc.Save(Folder + "Properties.pdf");
        }
コード例 #23
0
        public void RotateAt()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 200);

            doc.SaveState();
            doc.SetColor(1, 0, 0);
            doc.RotateAt(50, 20, 30);
            doc.DrawRectangle(50, 20, 100, 15);
            doc.RestoreState();

            doc.DrawRectangle(50, 20, 100, 15);

            doc.Save(Folder + "RotateAt.pdf");
        }
コード例 #24
0
        public void DrawText_Rotated()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 200);
            doc.SetFont("Arial", 12);
            for (int i = 0; i <= 360; i += 30)
            {
                doc.SaveState();
                doc.RotateAt(100, 100, i);
                doc.DrawText(100, 100, "Hello world!");
                doc.RestoreState();
            }

            doc.Save(Folder + "DrawText_Rotated.pdf");
        }
コード例 #25
0
        public void Translate()
        {
            var doc = new PortableDocument();

            doc.AddPage(200, 200);

            doc.SaveState();
            doc.SetColor(1, 0, 0);
            doc.Translate(20, 10);
            doc.DrawRectangle(10, 10, 100, 70);
            doc.RestoreState();

            doc.DrawRectangle(10, 10, 100, 70);

            doc.Save(Folder + "Translate.pdf");
        }
コード例 #26
0
        /// <summary>
        /// Saves the document at the specified path.
        /// </summary>
        /// <param name="doc">The document.</param>
        /// <param name="path">The path.</param>
        /// <param name="explore">Open Windows explorer on the specified path if set to <c>true</c>.</param>
        public static void Save(this PortableDocument doc, string path, bool explore = false)
        {
            var directory = Path.GetDirectoryName(path);

            if (directory != null && !Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            using (var stream = File.Create(path))
            {
                doc.Save(stream);
            }

            if (explore)
            {
                Process.Start("explorer.exe", "/select," + path);
            }
        }
コード例 #27
0
        public void FontFace(string fontName)
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);
            doc.SetFont(fontName, 12);
            double x  = 20 / 25.4 * 72;
            double dy = 10 / 25.4 * 72;
            double y  = doc.PageHeight - dy;

            doc.DrawText(x, y -= dy, "This is 12pt " + fontName + " regular.");
            doc.SetFont(fontName, 12, true);
            doc.DrawText(x, y -= dy, "This is 12pt " + fontName + " bold.");
            doc.SetFont(fontName, 12, false, true);
            doc.DrawText(x, y -= dy, "This is 12pt " + fontName + " italic.");
            doc.SetFont(fontName, 12, true, true);
            doc.DrawText(x, y, "This is 12pt " + fontName + " bold and italic.");
            doc.Save(Folder + "FontFace_" + fontName + ".pdf");
        }
コード例 #28
0
        public void MeasureText()
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);

            doc.SetFont("Arial", 96);

            var    text = "qjQJKæ";
            double width, height;

            doc.MeasureText(text, out width, out height);
            double y = doc.PageHeight - 400 - height;

            doc.SetColor(0, 0, 1);
            doc.DrawRectangle(50, y, width, height);
            doc.SetFillColor(0, 0, 0);
            doc.DrawText(50, y, text);
            doc.Save(Folder + "MeasureText.pdf");
        }
コード例 #29
0
        public void FontFaces()
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);
            double x  = 20 / 25.4 * 72;
            double dy = 10 / 25.4 * 72;
            double y  = doc.PageHeight - dy;

            doc.DrawText(x, y -= dy, "This is the default font.");
            doc.SetFont("Courier", 12);
            doc.DrawText(x, y -= dy, "This is courier normal.");
            doc.SetFont("Times", 12, false, true);
            doc.DrawText(x, y -= dy, "This is times italic.");
            doc.SetFont("Helvetica", 12, true);
            doc.DrawText(x, y -= dy, "This is helvetica bold.");
            doc.SetFont("Courier", 12, true, true);
            doc.DrawText(x, y, "This is courier bolditalic.");
            doc.Save(Folder + "FontFaces.pdf");
        }
コード例 #30
0
        public void DrawText_TopLeftCoordinateSystem()
        {
            var doc = new PortableDocument();

            doc.AddPage(PageSize.A4);
            doc.Transform(1, 0, 0, -1, 0, doc.PageHeight);
            doc.SetHorizontalTextScaling(-100);

            // Note: negative font size
            doc.SetFont("Arial", -20);
            doc.DrawText(5, 25, "Hello world!");

            doc.SetColor(OxyColors.Blue);
            doc.DrawCross(5, 25);

            doc.SetColor(OxyColors.Blue);
            doc.SetFillColor(OxyColors.LightBlue);
            doc.DrawEllipse(50, 100, 50, 40, true);

            doc.Save(Folder + "DrawText_TopLeftCoordinateSystem.pdf");
        }
コード例 #31
0
        public void DrawText_CharacterMap()
        {
            var doc = new PortableDocument();

            doc.AddPage(20 * 17, 20 * 17);
            doc.SetFont("Arial", 18);
            var sb = new StringBuilder();

            for (int i = 32; i < 256; i++)
            {
                double x = 10 + (20 * (i % 16));
                double y = doc.PageHeight - 10 - (20 * (i / 16));
                var    s = ((char)i).ToString(CultureInfo.InvariantCulture);
                doc.DrawText(x, y, s);
                sb.Append(s);
                if (i % 16 == 15)
                {
                    sb.AppendLine();
                }
            }

            doc.Save(Folder + "DrawText_CharacterMap.pdf");
            File.WriteAllText(Folder + "DrawText_CharacterMap.txt", sb.ToString(), Encoding.UTF8);
        }
コード例 #32
0
 public void DrawImage()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 100);
     //// var image = new PortableDocument.Image() { };
     //// doc.DrawImage(image);
     doc.Save(Folder + "DrawImage.pdf");
 }
コード例 #33
0
 public void DrawRectangle()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 100);
     doc.SetColor(OxyColors.Navy);
     doc.SetFillColor(OxyColors.Gainsboro);
     doc.DrawRectangle(5, 5, 100, 70, true);
     doc.DrawRectangle(185, 85, 10, 10);
     doc.Save(Folder + "DrawRectangle.pdf");
 }
コード例 #34
0
 public void FillRectangle()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 100);
     doc.SetColor(OxyColors.Gainsboro);
     doc.SetFillColor(OxyColors.Navy);
     doc.FillRectangle(5, 5, 100, 70);
     doc.Save(Folder + "FillRectangle.pdf");
 }
コード例 #35
0
        public void DrawText_TopLeftCoordinateSystem()
        {
            var doc = new PortableDocument();
            doc.AddPage(PageSize.A4);
            doc.Transform(1, 0, 0, -1, 0, doc.PageHeight);
            doc.SetHorizontalTextScaling(-100);

            // Note: negative font size
            doc.SetFont("Arial", -20);
            doc.DrawText(5, 25, "Hello world!");

            doc.SetColor(OxyColors.Blue);
            doc.DrawCross(5, 25);

            doc.SetColor(OxyColors.Blue);
            doc.SetFillColor(OxyColors.LightBlue);
            doc.DrawEllipse(50, 100, 50, 40, true);

            doc.Save(Folder + "DrawText_TopLeftCoordinateSystem.pdf");
        }
コード例 #36
0
 public void FillCircle()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 200);
     doc.SetColor(OxyColors.Blue);
     doc.SetFillColor(OxyColors.LightBlue);
     doc.FillCircle(100, 100, 95);
     doc.Save(Folder + "FillCircle.pdf");
 }
コード例 #37
0
        public void Translate()
        {
            var doc = new PortableDocument();
            doc.AddPage(200, 200);

            doc.SaveState();
            doc.SetColor(1, 0, 0);
            doc.Translate(20, 10);
            doc.DrawRectangle(10, 10, 100, 70);
            doc.RestoreState();

            doc.DrawRectangle(10, 10, 100, 70);

            doc.Save(Folder + "Translate.pdf");
        }
コード例 #38
0
 public void FontFaces()
 {
     var doc = new PortableDocument();
     doc.AddPage(PageSize.A4);
     double x = 20 / 25.4 * 72;
     double dy = 10 / 25.4 * 72;
     double y = doc.PageHeight - dy;
     doc.DrawText(x, y -= dy, "This is the default font.");
     doc.SetFont("Courier", 12);
     doc.DrawText(x, y -= dy, "This is courier normal.");
     doc.SetFont("Times", 12, false, true);
     doc.DrawText(x, y -= dy, "This is times italic.");
     doc.SetFont("Helvetica", 12, true);
     doc.DrawText(x, y -= dy, "This is helvetica bold.");
     doc.SetFont("Courier", 12, true, true);
     doc.DrawText(x, y, "This is courier bolditalic.");
     doc.Save(Folder + "FontFaces.pdf");
 }
コード例 #39
0
        public void DrawLine_LineWidths()
        {
            var doc = new PortableDocument();
            doc.AddPage(100, 100);
            double x = 0;
            double y0 = 78;
            double y1 = 10;

            doc.DrawLine(20, 95, 20, 80);

            doc.SetLineWidth(0.1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetLineWidth(1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetLineWidth(2);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetLineWidth(3);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.Save(Folder + "DrawLine_LineWidths.pdf");
        }
コード例 #40
0
        public void DrawLine_LineDashPatterns()
        {
            var doc = new PortableDocument();
            doc.AddPage(100, 100);
            double x0 = 10;
            double x1 = 40;
            double y = 100;
            double dy = -5;

            doc.SetLineWidth(1);

            // default dash pattern
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new double[] { }, 0);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 3d }, 0);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 2d }, 1);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 2d, 1 }, 0);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 3d, 5 }, 6);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.SetLineDashPattern(new[] { 2d, 3 }, 11);
            doc.DrawLine(x0, y += dy, x1, y);

            doc.Save(Folder + "DrawLine_LineDashPatterns.pdf");
        }
コード例 #41
0
        public void DrawLine_Colors()
        {
            var doc = new PortableDocument();
            doc.AddPage(100, 100);
            double x = 0;
            double y0 = 78;
            double y1 = 10;

            doc.DrawLine(10, 95, 10, 80);

            doc.SetColor(0, 0, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(1, 1, 1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(1, 0, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(0, 1, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(0, 0, 1);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.SetColor(1, 1, 0);
            doc.DrawLine(x += 10, y0, x, y1);

            doc.Save(Folder + "DrawLine_Colors.pdf");
        }
コード例 #42
0
 public void AddPage_EmptyDocument()
 {
     var doc = new PortableDocument();
     doc.AddPage(PageSize.A4);
     doc.Save(Folder + "EmptyDocument.pdf");
 }
コード例 #43
0
 public void DrawLine()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 100);
     doc.DrawLine(50, 50, 100, 70);
     doc.Save(Folder + "DrawLine.pdf");
 }
コード例 #44
0
 public void FillEllipse()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 100);
     doc.SetColor(OxyColors.Orange);
     doc.SetFillColor(OxyColors.LightGreen);
     doc.FillEllipse(5, 5, 190, 90);
     doc.Save(Folder + "FillEllipse.pdf");
 }
コード例 #45
0
 public void DrawEllipse()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 100);
     doc.SetColor(OxyColors.Orange);
     doc.SetFillColor(OxyColors.LightGreen);
     doc.DrawEllipse(5, 5, 190, 90, true);
     doc.DrawEllipse(175, 85, 20, 10);
     doc.Save(Folder + "DrawEllipse.pdf");
 }
コード例 #46
0
 public void SetClippingRectangle()
 {
     var doc = new PortableDocument();
     doc.AddPage(200, 200);
     doc.SetColor(OxyColors.Blue);
     doc.SetFillColor(OxyColors.LightBlue);
     doc.SaveState();
     doc.SetClippingRectangle(5, 5, 50, 50);
     doc.DrawCircle(100, 100, 95, true);
     doc.RestoreState();
     doc.DrawCircle(120, 120, 70);
     doc.Save(Folder + "SetClippingRectangle.pdf");
 }
コード例 #47
0
        public void MeasureText()
        {
            var doc = new PortableDocument();
            doc.AddPage(PageSize.A4);

            doc.SetFont("Arial", 96);

            var text = "qjQJKæ";
            double width, height;
            doc.MeasureText(text, out width, out height);
            double y = doc.PageHeight - 400 - height;
            doc.SetColor(0, 0, 1);
            doc.DrawRectangle(50, y, width, height);
            doc.SetFillColor(0, 0, 0);
            doc.DrawText(50, y, text);
            doc.Save(Folder + "MeasureText.pdf");
        }
コード例 #48
0
        public void ToPDF()
        {
            string pasta;
            string caminho;

            pasta = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;

            et.ExportPDFTotal();
            et.ExportPDF();

            caminho = Path.Combine(pasta, "ErgoMobile", "Exported", "temp", "new", "0resultado.pdf");
            if (File.Exists(caminho))
            {
                File.Delete(caminho);
            }
            using (var stream = File.Create(caminho))
            {
                var doc = new PortableDocument();
                doc.AddPage(OxyPlot.PageSize.A4);
                doc.Title  = relatorio;
                doc.Author = "ErgoMobile";
                doc.SetFont("Arial", 46);
                doc.DrawText(50, 420, relatorio);
                doc.SetFont("Arial", 30);
                doc.DrawText(200, 380, "ErgoMobile");
                doc.SetFont("Arial", 25);
                doc.DrawText(40, 140, inspecao);
                doc.SetFont("Arial", 18);
                doc.DrawText(40, 120, fileat + (Path.Combine(pasta, "ErgoMobile", "Exported")));
                doc.Save(stream);
            }


            caminho = Path.Combine(pasta, "ErgoMobile", "Exported", "temp", "new");
            CreateMergedPDF(Path.Combine(pasta, "ErgoMobile", "Exported", inspecao + ".pdf"), caminho);


            ///// DELETE TEMPORARY STUFF
            caminho = Path.Combine(pasta, "ErgoMobile", "Exported", "temp");
            System.IO.DirectoryInfo di = new DirectoryInfo(caminho);
            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                dir.Delete(true);
            }
            Directory.Delete(caminho);
            //System.Diagnostics.Process.Start(Path.Combine(pasta, "ErgoMobile", "Exported", inspecao + ".pdf"));
            //var uri = Android.Net.Uri.Parse(Path.Combine(pasta, "ErgoMobile", "Exported", inspecao + ".pdf"));

            //ABRIR RELATORIO GERADO
            Java.IO.File fl = new Java.IO.File(Path.Combine(pasta, "ErgoMobile", "Exported", inspecao + ".pdf"));
            fl.SetReadable(true);

            Android.Net.Uri uri    = Android.Net.Uri.FromFile(fl);
            var             intent = new Intent(Intent.ActionView);

            intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
            string application = "application/pdf";

            intent.SetDataAndType(uri, application);
            this.StartActivity(intent);
        }
コード例 #49
0
        public void Stroke_LineJoins()
        {
            var doc = new PortableDocument();
            doc.AddPage(100, 100);

            doc.SetLineWidth(3);
            doc.MoveTo(10, 10);
            doc.LineTo(50, 60);
            doc.LineTo(90, 10);
            doc.Stroke(false);

            doc.SetColor(1, 0, 0);
            doc.SetLineJoin(LineJoin.Bevel);
            doc.MoveTo(10, 20);
            doc.LineTo(50, 70);
            doc.LineTo(90, 20);
            doc.Stroke(false);

            doc.SetColor(0, 1, 0);
            doc.SetLineJoin(LineJoin.Miter);
            doc.MoveTo(10, 30);
            doc.LineTo(50, 80);
            doc.LineTo(90, 30);
            doc.Stroke(false);

            doc.SetColor(0, 0, 1);
            doc.SetLineJoin(LineJoin.Round);
            doc.MoveTo(10, 40);
            doc.LineTo(50, 90);
            doc.LineTo(90, 40);
            doc.Stroke(false);

            doc.Save(Folder + "Stroke_LineJoins.pdf");
        }
コード例 #50
0
        public void RotateAt()
        {
            var doc = new PortableDocument();
            doc.AddPage(200, 200);

            doc.SaveState();
            doc.SetColor(1, 0, 0);
            doc.RotateAt(50, 20, 30);
            doc.DrawRectangle(50, 20, 100, 15);
            doc.RestoreState();

            doc.DrawRectangle(50, 20, 100, 15);

            doc.Save(Folder + "RotateAt.pdf");
        }
コード例 #51
0
        public void Stroke_LineCaps()
        {
            var doc = new PortableDocument();
            doc.AddPage(100, 100);

            doc.SetColor(0.5, 0.5, 0.5);
            doc.SetLineWidth(3);
            doc.MoveTo(10, 10);
            doc.LineTo(50, 60);
            doc.LineTo(90, 10);
            doc.Stroke(false);

            doc.SetColor(1, 0, 0);
            doc.SetLineCap(LineCap.Butt);
            doc.MoveTo(10, 20);
            doc.LineTo(50, 70);
            doc.LineTo(90, 20);
            doc.Stroke(false);

            doc.SetColor(0, 1, 0);
            doc.SetLineCap(LineCap.ProjectingSquare);
            doc.MoveTo(10, 30);
            doc.LineTo(50, 80);
            doc.LineTo(90, 30);
            doc.Stroke(false);

            doc.SetColor(0, 0, 1);
            doc.SetLineCap(LineCap.Round);
            doc.MoveTo(10, 40);
            doc.LineTo(50, 90);
            doc.LineTo(90, 40);
            doc.Stroke(false);

            doc.SetColor(0, 0, 0);
            doc.SetLineWidth(0.1);
            doc.MoveTo(10, 10);
            doc.LineTo(50, 60);
            doc.LineTo(90, 10);
            doc.MoveTo(10, 20);
            doc.LineTo(50, 70);
            doc.LineTo(90, 20);
            doc.MoveTo(10, 30);
            doc.LineTo(50, 80);
            doc.LineTo(90, 30);
            doc.MoveTo(10, 40);
            doc.LineTo(50, 90);
            doc.LineTo(90, 40);
            doc.Stroke(false);

            doc.Save(Folder + "Stroke_LineCaps.pdf");
        }
コード例 #52
0
 public void FontFace(string fontName)
 {
     var doc = new PortableDocument();
     doc.AddPage(PageSize.A4);
     doc.SetFont(fontName, 12);
     double x = 20 / 25.4 * 72;
     double dy = 10 / 25.4 * 72;
     double y = doc.PageHeight - dy;
     doc.DrawText(x, y -= dy, "This is 12pt " + fontName + " regular.");
     doc.SetFont(fontName, 12, true);
     doc.DrawText(x, y -= dy, "This is 12pt " + fontName + " bold.");
     doc.SetFont(fontName, 12, false, true);
     doc.DrawText(x, y -= dy, "This is 12pt " + fontName + " italic.");
     doc.SetFont(fontName, 12, true, true);
     doc.DrawText(x, y, "This is 12pt " + fontName + " bold and italic.");
     doc.Save(Folder + "FontFace_" + fontName + ".pdf");
 }
コード例 #53
0
        public void DrawPolygon()
        {
            var doc = new PortableDocument();
            doc.AddPage(200, 100);

            doc.MoveTo(50, 30);
            doc.LineTo(170, 30);
            doc.LineTo(100, 70);
            doc.SetColor(OxyColors.Orange);
            doc.SetFillColor(OxyColors.LightGreen);
            doc.FillAndStroke();

            doc.MoveTo(5, 5);
            doc.LineTo(5, 25);
            doc.LineTo(25, 5);
            doc.Fill();

            doc.MoveTo(195, 95);
            doc.LineTo(175, 95);
            doc.LineTo(195, 75);
            doc.Stroke();

            doc.Save(Folder + "DrawPolygon.pdf");
        }
コード例 #54
0
        public void Transparency()
        {
            var doc = new PortableDocument();
            doc.AddPage(220, 100);
            doc.SetFillColor(OxyColors.Black);
            doc.FillRectangle(0, 45, 220, 10);
            for (int i = 0; i <= 10; i++)
            {
                doc.SetFillColor(OxyColor.FromAColor((byte)(255d * i / 10), OxyColors.Gold));
                doc.FillEllipse((i * 20) + 1, 41, 18, 18);
            }

            doc.Save(Folder + "Transparency.pdf");
        }
コード例 #55
0
        public void DrawText_Rotated2()
        {
            var doc = new PortableDocument();
            doc.AddPage(200, 200);
            doc.SetFont("Arial", 12);
            for (int i = 0; i <= 360; i += 30)
            {
                doc.SaveState();
                doc.Translate(100, 100);
                doc.Rotate(i);
                doc.DrawText(0, 0, "Hello world!");
                doc.RestoreState();
            }

            doc.Save(Folder + "DrawText_Rotated2.pdf");
        }
コード例 #56
0
        public void DrawText_CharacterMap()
        {
            var doc = new PortableDocument();
            doc.AddPage(20 * 17, 20 * 17);
            doc.SetFont("Arial", 18);
            var sb = new StringBuilder();
            for (int i = 32; i < 256; i++)
            {
                double x = 10 + (20 * (i % 16));
                double y = doc.PageHeight - 10 - (20 * (i / 16));
                var s = ((char)i).ToString(CultureInfo.InvariantCulture);
                doc.DrawText(x, y, s);
                sb.Append(s);
                if (i % 16 == 15)
                {
                    sb.AppendLine();
                }
            }

            doc.Save(Folder + "DrawText_CharacterMap.pdf");
            File.WriteAllText(Folder + "DrawText_CharacterMap.txt", sb.ToString(), Encoding.UTF8);
        }
コード例 #57
0
        private async void submit_Click(object sender, RoutedEventArgs e)
        {
            WriteableBitmap bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);

            bmpCurrentScreenImage.Render(ContentPanel, new MatrixTransform());
            bmpCurrentScreenImage.Invalidate();
            var fileName = String.Format("MyImage_{0:}.jpg", DateTime.Now.Ticks);

            SaveToMediaLibrary(bmpCurrentScreenImage, fileName, 100);
            MessageBox.Show("Image successfully Captured and saved!");
            string urlbase = String.Concat("http://searchtweets.bugs3.com/mail_image.php?to=", email.Text.Trim());

            Debug.WriteLine(email.Text + roll.Text);


            System.Diagnostics.Debug.WriteLine("Woah1!");
            var doc = new PortableDocument();

            System.Diagnostics.Debug.WriteLine("Woah2!");
            doc.Title = "Experiment";
            System.Diagnostics.Debug.WriteLine("Woah3!");
            doc.Author = "User_UnKnown";
            doc.AddPage(PageSize.A4);
            doc.SetFont("Arial", 48);
            doc.DrawText(doc.PageWidth / 4, doc.PageHeight - 50, "Experiment Info");
            doc.DrawLine(0, doc.PageHeight - 60, doc.PageWidth, doc.PageHeight - 60);

            //doc.DrawImage(portableImage);
            doc.SetFont("Arial", 24);
            System.Diagnostics.Debug.WriteLine("Woah4!");
            double xi = 50;
            double yi = doc.PageHeight - 200;

            foreach (DataPoint d in list_new)
            {
                doc.DrawText(xi, yi, "X:" + d.X.ToString() + " Y: " + d.Y.ToString());
                yi = yi - 50;
            }

            doc.DrawText(50, 400, "End of Document");
            //doc.DrawImage(portableImage);
            doc.Save(TestStream());
            System.Diagnostics.Debug.WriteLine("Woah5!");
            if (File.Exists("exampleExperiment1.pdf"))
            {
                System.Diagnostics.Debug.WriteLine("It Does Exist!");
                FileStream    pdfFile2 = File.OpenRead("exampleExperiment1.pdf");
                StorageFolder local    = Windows.Storage.ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;

                System.Diagnostics.Debug.WriteLine(Path.GetFullPath("exampleExperiment1.pdf"));
                System.Diagnostics.Debug.WriteLine(installedLocation.Path);
                // Access the PDF.
                //StorageFile pdfFile = await local.GetFileAsync("C:\\Data\\Programs\\{61044A2A-FAB3-4925-BDAE-498DEB9E35EA}\\Install\\exampleExperiment1.pdf");
                //Windows.System.Launcher.LaunchFileAsync(pdfFile);
                StorageFile pdfFile = await installedLocation.GetFileAsync("exampleExperiment1.pdf");

                Windows.System.Launcher.LaunchFileAsync(pdfFile);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Sorry Man! It Doesn't");
            }
        }