Ejemplo n.º 1
0
        internal RectangleF RenderParagraph(string text, Font font, RectangleF rcPage, RectangleF rc, bool outline, bool linkTarget)
        {
            // if it won't fit this page, do a page break
            rc.Height = _c1pdf.MeasureString(text, font, rc.Width).Height;
            if (rc.Bottom > rcPage.Bottom)
            {
                _c1pdf.NewPage();
                rc.Y = rcPage.Top;
            }

            // draw the string
            _c1pdf.DrawString(text, font, Brushes.Black, rc);

            // add headings to outline
            if (outline)
            {
                _c1pdf.DrawLine(Pens.Black, rc.X, rc.Y, rc.Right, rc.Y);
                _c1pdf.AddBookmark(text, 0, rc.Y);
            }

            // add link target
            if (linkTarget)
            {
                _c1pdf.AddTarget(text, rc);
            }

            // update rectangle for next time
            rc.Offset(0, rc.Height);
            return(rc);
        }
Ejemplo n.º 2
0
        private void button8_Click(object sender, System.EventArgs e)
        {
            // initialize
            C1.C1Pdf.C1PdfDocument pdf = new C1.C1Pdf.C1PdfDocument();

            // create a regular (external) hyperlink
            RectangleF rc   = new RectangleF(50, 50, 200, 15);
            Font       font = new Font("Arial", 10, FontStyle.Underline);

            pdf.AddLink("http://www.componentone.com", rc);
            pdf.DrawString("Visit ComponentOne", font, Brushes.Blue, rc);

            // create a link target
            pdf.AddTarget("#myLink", rc);

            // add a few pages
            for (int i = 0; i < 5; i++)
            {
                pdf.NewPage();
            }

            // add a link to the target
            pdf.AddLink("#myLink", rc);
            pdf.FillRectangle(Brushes.BlanchedAlmond, rc);
            pdf.DrawString("Local link: back to page 1...", font, Brushes.Blue, rc);

            // save and show
            string fileName = tempdir + "links.pdf";

            pdf.Save(fileName);
            System.Diagnostics.Process.Start(fileName);
        }