Beispiel #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            // render both reports to generate PageImages collections
            _c1rPortrait.Render();
            _c1rLandscape.Render();

            // start a new pdf document
            _c1pdf.Clear();
            int cnt = 0;

            // add portrait pages
            _c1pdf.PaperKind = PaperKind.Letter;
            foreach (Image img in _c1rPortrait.PageImages)
            {
                if (cnt > 0)
                {
                    _c1pdf.NewPage();
                }
                _c1pdf.Landscape = false;
                _c1pdf.DrawImage(img, _c1pdf.PageRectangle);
                cnt++;
            }

            // add landscape pages
            foreach (Image img in _c1rLandscape.PageImages)
            {
                if (cnt > 0)
                {
                    _c1pdf.NewPage();
                }
                _c1pdf.Landscape = true;
                _c1pdf.DrawImage(img, _c1pdf.PageRectangle);
                cnt++;
            }

            // save the document
            string appPath = Application.StartupPath + "\\mixed.pdf";

            _c1pdf.Save(appPath);

            DialogResult dr = MessageBox.Show("Resulting sample pdf found at:\r\n\r\n" +
                                              appPath + "\r\n\r\nDo you wish to launch?", "", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                Process p = new Process();
                p.StartInfo.FileName = appPath;
                p.Start();
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            _pdf.Clear();

            Rectangle    rcell = new Rectangle(72, 72, 36, 36);
            StringFormat sf    = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            Font f1  = new Font("Tahoma", rcell.Height / 2);
            Font f2  = new Font("Tahoma", rcell.Height / 6);
            Pen  pen = new Pen(Brushes.Black, 0.1f);

            int col = 0;

            for (char c = (char)32; c <= (char)256; c++)
            {
                // show this character
                _pdf.DrawRectangle(pen, rcell);
                _pdf.DrawString(c.ToString(), f1, Brushes.Black, rcell, sf);

                rcell.Width  /= 2;
                rcell.Height /= 4;
                _pdf.DrawRectangle(pen, rcell);
                _pdf.DrawString(((int)c).ToString(), f2, Brushes.Black, rcell, sf);
                rcell.Width  *= 2;
                rcell.Height *= 4;

                // increment rectangle
                col++;
                if (col >= 12)
                {
                    col      = 0;
                    rcell.X  = 72;
                    rcell.Y += rcell.Height;
                }
                else
                {
                    rcell.X += rcell.Width;
                }
            }

            string tempdir = Application.ExecutablePath.Substring(0,
                                                                  Application.ExecutablePath.LastIndexOf("\\") + 1);
            string fname = tempdir + "chartbl.pdf";

            _pdf.Save(fname);
            System.Diagnostics.Process.Start(fname);
        }
Beispiel #3
0
        private void CreatePDF()
        {
            _c1pdf = new C1.C1Pdf.C1PdfDocument();
            //start document
            _c1pdf.Clear();
            TEMP_DIR = Server.MapPath("../Temp");
            if (Directory.Exists(TEMP_DIR))
            {

            }
            else
            {
                Directory.CreateDirectory(TEMP_DIR);

            }
            //prepare to draw with Gdi-like commands
            int penWidth = 0;
            int penRGB = 0;
            Rectangle rc = new Rectangle(50, 50, 300, 200);
            string text = "Hello world of .NET Graphics and PDF.\r\nNice to meet you.";
            Font font = new Font("Times New Roman", 16, FontStyle.Italic | FontStyle.Underline);

            //start, c1, c2, end1, c3, c4, end
            PointF[] bezierPoints = new PointF[]
			{
				new PointF(110f, 200f), new PointF(120f, 110f), new PointF(135f, 150f),
				new PointF(150f, 200f), new PointF(160f, 250f), new PointF(165f, 200f),
				new PointF(150f, 100f)
			};

            //draw to pdf document
            C1.C1Pdf.C1PdfDocument g = _c1pdf;
            g.FillPie(Brushes.Red, rc, 0, 20f);
            g.FillPie(Brushes.Green, rc, 20f, 30f);
            g.FillPie(Brushes.Blue, rc, 60f, 12f);
            g.FillPie(Brushes.Gold, rc, -80f, -20f);
            for (float sa = 0; sa < 360; sa += 40)
            {
                Color penColor = Color.FromArgb(penRGB, penRGB, penRGB);
                Pen pen = new Pen(penColor, penWidth++);
                penRGB = penRGB + 20;
                g.DrawArc(pen, rc, sa, 40f);
            }
            g.DrawRectangle(Pens.Red, rc);
            g.DrawBeziers(Pens.Blue, bezierPoints);
            g.DrawString(text, font, Brushes.Black, rc);
        }
Beispiel #4
0
        private void CreatePDF()
        {
            _c1pdf = new C1.C1Pdf.C1PdfDocument();
            //start document
            _c1pdf.Clear();
            TEMP_DIR = Server.MapPath("../Temp");
            if (Directory.Exists(TEMP_DIR))
            {
            }
            else
            {
                Directory.CreateDirectory(TEMP_DIR);
            }
            //prepare to draw with Gdi-like commands
            int       penWidth = 0;
            int       penRGB   = 0;
            Rectangle rc       = new Rectangle(50, 50, 300, 200);
            string    text     = "Hello world of .NET Graphics and PDF.\r\nNice to meet you.";
            Font      font     = new Font("Times New Roman", 16, FontStyle.Italic | FontStyle.Underline);

            //start, c1, c2, end1, c3, c4, end
            PointF[] bezierPoints = new PointF[]
            {
                new PointF(110f, 200f), new PointF(120f, 110f), new PointF(135f, 150f),
                new PointF(150f, 200f), new PointF(160f, 250f), new PointF(165f, 200f),
                new PointF(150f, 100f)
            };

            //draw to pdf document
            C1.C1Pdf.C1PdfDocument g = _c1pdf;
            g.FillPie(Brushes.Red, rc, 0, 20f);
            g.FillPie(Brushes.Green, rc, 20f, 30f);
            g.FillPie(Brushes.Blue, rc, 60f, 12f);
            g.FillPie(Brushes.Gold, rc, -80f, -20f);
            for (float sa = 0; sa < 360; sa += 40)
            {
                Color penColor = Color.FromArgb(penRGB, penRGB, penRGB);
                Pen   pen      = new Pen(penColor, penWidth++);
                penRGB = penRGB + 20;
                g.DrawArc(pen, rc, sa, 40f);
            }
            g.DrawRectangle(Pens.Red, rc);
            g.DrawBeziers(Pens.Blue, bezierPoints);
            g.DrawString(text, font, Brushes.Black, rc);
        }
Beispiel #5
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            // render both reports to generate PageImages collections
            _c1rPortrait.Render();
            _c1rLandscape.Render();

            // start a new pdf document
            _c1pdf.Clear();
            int cnt = 0;

            // add portrait pages
            _c1pdf.PaperKind = PaperKind.Letter;
            foreach (Image img in _c1rPortrait.PageImages)
            {
                if (cnt > 0)
                {
                    _c1pdf.NewPage();
                }
                _c1pdf.Landscape = false;
                _c1pdf.DrawImage(img, _c1pdf.PageRectangle);
                cnt++;
            }

            // add landscape pages
            foreach (Image img in _c1rLandscape.PageImages)
            {
                if (cnt > 0)
                {
                    _c1pdf.NewPage();
                }
                _c1pdf.Landscape = true;
                _c1pdf.DrawImage(img, _c1pdf.PageRectangle);
                cnt++;
            }

            // save the document
            string tempdir = Application.ExecutablePath.Substring(0,
                                                                  Application.ExecutablePath.LastIndexOf("\\") + 1);

            _c1pdf.Save(tempdir + "mixed.pdf");
            Process.Start(tempdir + "mixed.pdf");
        }
Beispiel #6
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            // render both reports to generate PageImages collections
            _c1rPortrait.Render();
            _c1rLandscape.Render();

            // start a new pdf document
            _c1pdf.Clear();
            int cnt = 0;

            // add portrait pages
            _c1pdf.PaperKind = PaperKind.Letter;
            foreach (Image img in _c1rPortrait.PageImages)
            {
                if (cnt > 0)
                {
                    _c1pdf.NewPage();
                }
                _c1pdf.Landscape = false;
                _c1pdf.DrawImage(img, _c1pdf.PageRectangle);
                cnt++;
            }

            // add landscape pages
            foreach (Image img in _c1rLandscape.PageImages)
            {
                if (cnt > 0)
                {
                    _c1pdf.NewPage();
                }
                _c1pdf.Landscape = true;
                _c1pdf.DrawImage(img, _c1pdf.PageRectangle);
                cnt++;
            }

            // save the document
            _c1pdf.Save(@"c:\temp\mixed.pdf");
        }
Beispiel #7
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            // start document
            _c1pdf.Clear();
            _c1pdf.Security.AllowPrint = false;
            //_c1pdf.Security.UserPassword = "******";
            //_c1pdf.Landscape = true;

            // build page and chart rectangles
            RectangleF rcPage = _c1pdf.PageRectangle;

            rcPage.Inflate(-60, -72);
            rcPage.X = 72;
            RectangleF rcChart = new RectangleF(rcPage.X, rcPage.Y, 160, 160);

            // show title
            Font       font = new Font("Tahoma", 16, FontStyle.Bold);
            string     text = "Pdf charts created with the C1Chart control.";
            RectangleF rc   = rcPage;

            rc.Y = rcPage.Y - 24;
            _c1pdf.DrawString(text, font, Brushes.DarkGray, rc);

            // scan controls on the selected tab page and render charts
            foreach (Control c in tabControl1.SelectedTab.Controls)
            {
                // skip invisible controls
                if (!c.Visible)
                {
                    continue;
                }

                // get chart control
                C1.Win.C1Chart.C1Chart     c2d = c as C1.Win.C1Chart.C1Chart;
                C1.Win.C1Chart3D.C1Chart3D c3d = c as C1.Win.C1Chart3D.C1Chart3D;

                // get metafile from chart control
                label1.Text = string.Format("Getting image from {0}...", c.Name);
                label1.Update();
                Metafile meta = null;
                if (c2d != null)
                {
                    meta = (Metafile)c2d.GetImage();
                }
                if (c3d != null)
                {
                    meta = (Metafile)c3d.GetImage();
                }

                // make sure we got the metafile
                if (meta == null)
                {
                    continue;
                }

                // draw it, frame it, and move on
                label1.Text = string.Format("Exporting {0}...", c.Name);
                label1.Update();
                _c1pdf.DrawImage(meta, rcChart);
                _c1pdf.DrawRectangle(Pens.SteelBlue, rcChart);
                rcChart = NextChartRect(rcChart, rcPage);
            }
            label1.Text = string.Empty;

            // save document and show it
            string tempdir = Application.ExecutablePath.Substring(0,
                                                                  Application.ExecutablePath.LastIndexOf("\\") + 1);
            string fileName = string.Format(tempdir + @"{0}.pdf", tabControl1.SelectedTab.Text);

            _c1pdf.Save(fileName);
            Process.Start(fileName);
        }
Beispiel #8
0
        private void DumpMetas(string mask)
        {
            Cursor = Cursors.WaitCursor;

            _c1pdf.Clear();
            _c1pdf.Compression = C1.C1Pdf.CompressionEnum.None;
            //_c1pdf.Compression = C1.C1Pdf.CompressionEnum.BestCompression;
            Random rnd  = new Random();
            Font   font = new Font("Courier New", 9, FontStyle.Bold);

            // look for emf files in the executable directory
            string path  = Path.GetDirectoryName(Application.ExecutablePath);
            bool   first = true;

            string[] files = Directory.GetFiles(path, mask);
            foreach (string fileName in files)
            {
                statusBar1.Text = string.Format("Exporting {0}...", Path.GetFileName(fileName));
                Application.DoEvents();

                // new page
                if (!first)
                {
                    _c1pdf.NewPage();
                }
                first = false;

                // load metafile
                Metafile meta = (Metafile)Metafile.FromFile(fileName);

                // get metafile size in points
                SizeF szPage = GetImageSizeInPoints(meta);
                Console.WriteLine("Adding page {0:f2}\" x {1:f2}\"", szPage.Width / 72f, szPage.Height / 72f);

                // size page to metafile
                _c1pdf.PageSize = szPage;

                // draw metafile on the page
                RectangleF rc = _c1pdf.PageRectangle;
                _c1pdf.FillRectangle(Brushes.AntiqueWhite, rc);
                _c1pdf.DrawImage(meta, rc);
                _c1pdf.DrawString(fileName, font, Brushes.Black, rc);

                // draw thumbnail at random place
                rc.Width  /= 5;
                rc.Height /= 5;
                rc.X       = rnd.Next((int)(szPage.Width - rc.Width));
                rc.Y       = rnd.Next((int)(szPage.Height - rc.Height));
                _c1pdf.FillRectangle(Brushes.White, rc);
                _c1pdf.DrawImage(meta, rc);
                _c1pdf.DrawRectangle(Pens.Black, rc);

                // add outline entry if there's more than one page
                if (files.Length > 1)
                {
                    _c1pdf.AddBookmark(Path.GetFileName(fileName), 0, 0);
                }
            }

            // show the result
            statusBar1.Text = "Saving...";
            SaveAndShow(@"c:\temp\test\metas.pdf");
            Cursor          = Cursors.Default;
            statusBar1.Text = "Ready";
        }