예제 #1
0
        //=============================================================================
        // create a document with some rtf in it
        private void button2_Click(object sender, System.EventArgs e)
        {
            _c1pdf.Clear();
            _c1pdf.PaperKind   = PaperKind.Letter;
            _c1pdf.Compression = C1.C1Pdf.CompressionEnum.None;

            // load rtf
            StreamReader sr      = new StreamReader(Application.StartupPath + @"\zip.rtf");
            string       rtfText = sr.ReadToEnd();

            sr.Close();

            // render rtf onto the page as usual text
            RectangleF rc = _c1pdf.PageRectangle;

            rc.Inflate(-72, -72);
            _c1pdf.DrawStringRtf(rtfText, null, null, rc);
            _c1pdf.DrawRectangle(Pens.BlueViolet, rc);

            // render again on a new page
            _c1pdf.NewPage();
            rc    = _c1pdf.PageRectangle;
            rc.X += 50; rc.Width -= 180;
            rc.Y += 50; rc.Height -= 180;

            // this time measure the text first and adjust the height of the
            // rectangle to fit exactly.
            rc.Size = _c1pdf.MeasureStringRtf(rtfText, null, rc.Width);
            _c1pdf.DrawStringRtf(rtfText, null, null, rc);
            _c1pdf.DrawRectangle(Pens.BlueViolet, rc);

            // done
            SaveAndShow(@"c:\temp\test\rtf.pdf");
        }