⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cover.cs

📁 PDF文档生成解析使用的库,可以用来改写自己的文档格式
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using AnotherPDFLib.Forms;
using AnotherPDFLib.XFA;

namespace AnotherPDFLibTest
{
    public partial class ApplyBaiYuLanFund
    {
        public class Cover
        {
            public static Form CreateForm(Page page)
            {
                Form cover = new Form("cover");
                cover.Location = page.ContentArea.Location;
                cover.Size = page.ContentArea.Size;

                @break pageBreak = new @break();
                pageBreak.startNew = true;
                pageBreak.after = breakTarget.pageArea;
                pageBreak.afterTarget = "#A4Page";
                cover.Break = pageBreak;

                Label title = CreateTitle();
                title.Top = 120;
                cover.ApplyAlignment(Alignment.Center, title);
                cover.Controls.Add(title);

                Label subtitle = CreateSubTitle();
                subtitle.Top = title.Bottom;
                cover.ApplyAlignment(Alignment.Center, subtitle);
                cover.Controls.Add(subtitle);

                TextBox appliername = CreateBlankFilling("appliername", "申 请 人", 378);
                appliername.Top = subtitle.Bottom + 100;
                cover.ApplyAlignment(Alignment.Center, appliername);
                cover.Controls.Add(appliername);
                TextBox applytimespan = CreateBlankFilling("applytimespan", "起止年月", 378);
                TextBox applyunitname = CreateBlankFilling("applyunitname", "依托单位", 378);
                TextBox applieraddress = CreateBlankFilling("applieraddress", "通讯地址", 378);

                TextBox applierphone = CreateBlankFilling("applierphone", "联系电话", 214);
                TextBox applierzip = CreateBlankFilling("applierzip", "邮政编码", 164);
                TextBox appliermobile = CreateBlankFilling("appliermobile", "手    机", 214);
                TextBox applieremail = CreateBlankFilling("applieremail", "E-mail", 164);

                AddCenteredControl(cover, applytimespan);
                AddCenteredControl(cover, applyunitname);
                AddCenteredControl(cover, applieraddress);
                AddLeftControl(cover, applierphone);
                AddLeftControl(cover, appliermobile);
                AddRightControl(cover, applierzip);
                AddRightControl(cover, applieremail);

                Label gaizhang = new Label();
                gaizhang.Text = "(盖章)";
                gaizhang.Font = new Font("仿宋_GB2312", 12);
                gaizhang.LineHeight = 32;
                gaizhang.CalculateSize();
                gaizhang.Top = applyunitname.Top;
                gaizhang.Left = applyunitname.Right;
                cover.Controls.Add(gaizhang);

                Label datefilling = new Label();
                datefilling.Text = "20    年    月    日订";
                datefilling.Font = new Font("仿宋_GB2312", 12);
                datefilling.LineHeight = 32;
                datefilling.CalculateSize();
                datefilling.Top = applieremail.Bottom + 100;
                cover.ApplyAlignment(Alignment.Center, datefilling);
                cover.Controls.Add(datefilling);

                return cover;
            }

            private static void AddCenteredControl(Form cover, TextBox txtbox)
            {
                Control previousbox = cover.Controls[cover.Controls.Count - 1];
                txtbox.Top = previousbox.Bottom;
                cover.ApplyAlignment(Alignment.Center, txtbox);
                cover.Controls.Add(txtbox);
            }

            private static void AddLeftControl(Form cover, TextBox txtbox)
            {
                Control previousbox = cover.Controls[cover.Controls.Count - 1];
                txtbox.Top = previousbox.Bottom;
                txtbox.Left = previousbox.Left;
                cover.Controls.Add(txtbox);
            }

            private static void AddRightControl(Form cover, TextBox txtbox)
            {
                Control previousbox = cover.Controls[cover.Controls.Count - 2];
                txtbox.Top = previousbox.Top;
                txtbox.Left = previousbox.Right;
                cover.Controls.Add(txtbox);
            }

            private static TextBox CreateBlankFilling(string name, string caption, float width)
            {
                TextBox txtbox = new TextBox();
                txtbox.Name = name;
                Label captionlabel = new Label();
                captionlabel.Text = caption;
                captionlabel.Font = new Font("仿宋_GB2312", 15);
                txtbox.Caption = captionlabel;
                txtbox.Border.Bottom = new Border();
                txtbox.Padding.Bottom = 2;
                txtbox.TextAlign = Alignment.BottomCenter;
                txtbox.Width = width;
                txtbox.Height = 32;
                txtbox.Font = new Font("仿宋_GB2312", 15);
                return txtbox;
            }

            private static Label CreateTitle()
            {
                Label title = new Label();
                title.Name = "title";
                title.Text =
    @"上海市科学技术委员会
上海市白玉兰科技人才基金申请表";
                title.Font = new Font("黑体", 26);
                title.TextAlign = Alignment.MiddleCenter;
                title.LineHeight = 48;
                title.CalculateSize();
                return title;
            }

            private static Label CreateSubTitle()
            {
                Label subtitle = new Label();
                subtitle.Name = "subtitle";
                subtitle.Text = "(2005年版)";
                subtitle.Font = new Font("黑体", 18);
                subtitle.TextAlign = Alignment.MiddleCenter;
                subtitle.LineHeight = 48;
                subtitle.CalculateSize();
                return subtitle;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -