예제 #1
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");
 }
        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");
        }
예제 #3
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);
 }
        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");
        }
        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");
        }
        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);
        }
        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");
        }
        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");
        }
예제 #9
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");
        }
        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");
        }
        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);
        }
예제 #12
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");
 }
예제 #13
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");
 }
예제 #14
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");
        }
예제 #15
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");
        }
        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);
        }
예제 #17
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);
        }
예제 #18
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");
            }
        }