예제 #1
0
        // measure a paragraph, skip a page if it won't fit, render it into a rectangle,
        // and update the rectangle for the next paragraph.
        //
        // optionally mark the paragraph as an outline entry and as a link target.
        //
        // this routine will not break a paragraph across pages. for that, see the Text Flow sample.
        //
        public static Rect RenderParagraph(C1PdfDocument pdf, string text, Font font, Rect rcPage, Rect rc, bool outline, bool linkTarget)
        {
            // if it won't fit this page, do a page break
            rc.Height = pdf.MeasureString(text, font, rc.Width).Height;
            if (rc.Bottom > rcPage.Bottom)
            {
                pdf.NewPage();
                rc.Y = rcPage.Top;
            }

            // draw the string
            pdf.DrawString(text, font, Colors.Black, rc);

            // show bounds (mainly to check word wrapping)
            //pdf.DrawRectangle(Pens.Sienna, rc);

            // add headings to outline
            if (outline)
            {
                pdf.DrawLine(new Pen(Colors.Black), rc.X, rc.Y, rc.Right, rc.Y);
                pdf.AddBookmark(text, 0, rc.Y);
            }

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

            // update rectangle for next time
            rc.Y += rc.Height;
            //rc.Offset(0, rc.Height);
            return(rc);
        }
예제 #2
0
        static Rect RenderTable(C1PdfDocument pdf, Rect rc, Rect rcPage, DataTable table, string[] fields)
        {
            // select fonts
            Font hdrFont = new Font("Tahoma", 10, PdfFontStyle.Bold);
            Font txtFont = new Font("Tahoma", 8);

            // build table
            pdf.AddBookmark(table.TableName, 0, rc.Y);
            rc = PdfUtils.RenderParagraph(pdf, "NorthWind " + table.TableName, hdrFont, rcPage, rc, false);

            // build table
            rc = RenderTableHeader(pdf, hdrFont, rc, fields);
            foreach (DataRow dr in table.Rows)
            {
                rc = RenderTableRow(pdf, txtFont, hdrFont, rcPage, rc, fields, dr);
            }

            // done
            return(rc);
        }
예제 #3
0
        static Rect RenderTable(C1PdfDocument pdf, Rect rc, Rect rcPage, DataTable table, string[] fields)
        {
            // select fonts
            Font hdrFont = new Font("Tahoma", 10, PdfFontStyle.Bold);
            Font txtFont = new Font("Tahoma", 8);

            // build table
            pdf.AddBookmark(table.TableName, 0, rc.Y);
            rc = PdfUtils.RenderParagraph(pdf, "NorthWind " + table.TableName, hdrFont, rcPage, rc, false);

            // build table
            rc = RenderTableHeader(pdf, hdrFont, rc, fields);
            foreach (DataRow dr in table.Rows)
            {
                rc = RenderTableRow(pdf, txtFont, hdrFont, rcPage, rc, fields, dr);
            }

            // done
            return rc;
        }