找回密码
 立即注册

QQ登录

只需一步,快速开始

frank.zhang

社区贡献组

83

主题

4000

帖子

6万

积分

社区贡献组

积分
69459

活字格认证微信认证勋章元老葡萄

frank.zhang
社区贡献组   /  发表于:2015-2-17 11:30  /   查看:4422  /  回复:0
问题描述:用C1PDF控件从应用程序创建支持AcroForm的PDF文件
问题解答:C1PDF控件将内容添加到文档所使用的命令与.NET Graphics类中的命令类似。同时,PDF for .NET控件提供安全、压缩、大纲、超链接,以及附件等功能。

关键代码:
  1. // add text box field for fields of the PDF document
  2.        // with common parameters and default names.
  3.        //
  4.        internal PdfTextBox RenderTextBox(string text, Font font, RectangleF rc, Color back, string toolTip)
  5.        {
  6.            // create
  7.            string name = string.Format("ACFTB{0}", _textBoxCount + 1);
  8.            PdfTextBox textBox = new PdfTextBox();

  9.            // default border
  10.            //textBox.BorderWidth = 3f / 4;
  11.            textBox.BorderStyle = FieldBorderStyle.Solid;
  12.            textBox.BorderColor = SystemColors.ControlDarkDark;

  13.            // parameters
  14.            textBox.Font = font;
  15.            textBox.Name = name;
  16.            textBox.DefaultText = text;
  17.            textBox.Text = text;
  18.            textBox.ToolTip = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
  19.            if (back != Color.Transparent && !back.IsEmpty)
  20.            {
  21.                textBox.BackColor = back;
  22.            }

  23.            // add
  24.            _c1pdf.AddField(textBox, rc);
  25.            _textBoxCount++;

  26.            // done
  27.            return textBox;
  28.        }
  29.        internal PdfTextBox RenderTextBox(string text, Font font, RectangleF rc, Color back)
  30.        {
  31.            return RenderTextBox(text, font, rc, back, null);
  32.        }
  33.        internal PdfTextBox RenderTextBox(string text, Font font, RectangleF rc)
  34.        {
  35.            return RenderTextBox(text, font, rc, Color.Transparent, null);
  36.        }
复制代码


效果截图:



源码下载:
用C1PDF控件从应用程序创建支持AcroForm的PDF文件示例

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部