PDF文件导出

记录一个.NET 生成PDF文件的代码

   //指定项目下的一个文件夹 用于存储生成的PDF文件 
   var directory = "/PDF/Common/";
   //获取这个文件夹在本地的绝对路径
   var fullDirectory = HttpContext.Current.Server.MapPath(directory);
   //如果这个文件夹不存在,则创建这个文件夹
   if (!Directory.Exists(fullDirectory)) Directory.CreateDirectory(fullDirectory);
   //文件名称用生成的GUID代替
   string fileName = string.Format("{0}.pdf", Guid.NewGuid().ToString());
   //定义本地路径
   string LocalFilePath = "";

        private static readonly String cnNumber = "零壹贰叁肆伍陆柒捌玖";
        private static readonly String cnUnit = "分角元拾佰仟万拾佰仟亿拾佰仟兆拾佰仟";

        /// <summary> 
        /// 转换人民币大小金额 
        /// </summary> 
        /// <param name="num">金额</param> 
        /// <returns>返回大写形式</returns> 
        public static string GetUpper(decimal num)
        {
            String[] tmpString = num.ToString().Split('.');
            String intString = num.ToString();   // 默认为整数
            String decString = "";            // 保存小数部分字串
            String rmbCapital = "";            // 保存中文大写字串
            int k;
            int j;
            int n;

            if (tmpString.Length > 1)
            {
                intString = tmpString[0];             // 取整数部分
                decString = tmpString[1];             // 取小数部分
            }
            decString += "00";
            decString = decString.Substring(0, 2);   // 保留两位小数位
            intString += decString;

            try
            {
                k = intString.Length - 1;
                if (k > 0 && k < 18)
                {
                    for (int i = 0; i <= k; i++)
                    {
                        j = (int)intString[i] - 48;
                        // rmbCapital = rmbCapital + cnNumber[j] + cnUnit[k-i];     // 供调试用的直接转换
                        n = i + 1 >= k ? (int)intString[k] - 48 : (int)intString[i + 1] - 48; // 等效于 if( ){ }else{ }
                        if (j == 0)
                        {
                            if (k - i == 2 || k - i == 6 || k - i == 10 || k - i == 14)
                            {
                                rmbCapital += cnUnit[k - i];
                            }
                            else
                            {
                                if (n != 0)
                                {
                                    rmbCapital += cnNumber[j];
                                }
                            }
                        }
                        else
                        {
                            rmbCapital = rmbCapital + cnNumber[j] + cnUnit[k - i];
                        }
                    }

                    rmbCapital = rmbCapital.Replace("兆亿万", "兆");
                    rmbCapital = rmbCapital.Replace("兆亿", "兆");
                    rmbCapital = rmbCapital.Replace("亿万", "亿");
                    rmbCapital = rmbCapital.TrimStart('元');
                    rmbCapital = rmbCapital.TrimStart('零');

                    string lastStr = rmbCapital.Substring(rmbCapital.Length - 1);
                    if (lastStr == "元" || lastStr == "角")
                        rmbCapital += "整";
                    return rmbCapital;
                }
                else
                {
                    return "";   // 超出转换范围时,返回零长字串
                }
            }
            catch
            {
                return "";   // 含有非数值字符时,返回零长字串
            }
        }


        #region 对文件绘制表格
        /// <summary>
        /// 对文件绘制表格
        /// </summary>
        /// <param name="row"></param>
        /// <param name="font"></param>
        /// <param name="Content"></param>
        /// <param name="BorderWidth"></param>
        /// <param name="VerticalAlignment"></param>
        /// <param name="HorizontalAlignment"></param>
        /// <param name="Colspan"></param>
        /// <param name="PaddingLeft"></param>
        /// <param name="PaddingTop"></param>
        /// <param name="PaddingRight"></param>
        /// <param name="PaddingBottom"></param>
        /// <param name="r"></param>
        /// <param name="setLeading"></param>
        /// <param name="Rowspan"></param>
        /// <param name="BorderWidthTop"></param>
        public static void WriteCell(PdfPTable row, Font font, string Content, float BorderWidth = 0, int VerticalAlignment = PdfPCell.ALIGN_MIDDLE, int HorizontalAlignment = PdfPCell.ALIGN_CENTER, int Colspan = 0, float PaddingLeft = 5, float PaddingTop = 5, float PaddingRight = 5, float PaddingBottom = 5, int r = 0, float setLeading = 0.6F, int Rowspan = 0, int BorderWidthTop = 1)
        {
            PdfPCell cell = new PdfPCell(new Paragraph(Content, font));
            //设置行间距
            cell.SetLeading(10, setLeading);
            if (Colspan > 0)
                cell.Colspan = Colspan;
            if (Rowspan > 0)
                cell.Rowspan = Rowspan;
            cell.VerticalAlignment = VerticalAlignment;
            cell.HorizontalAlignment = HorizontalAlignment;
            //避免重复画边框导致过粗
            if (BorderWidth != 0)
            {
                if (BorderWidthTop > 0)
                    cell.BorderWidthTop = BorderWidth;
                else
                    cell.BorderWidthTop = Rectangle.NO_BORDER;
                cell.BorderWidthRight = BorderWidth;
                if (r == 0)
                {
                    cell.BorderWidthLeft = BorderWidth;
                    cell.BorderWidthBottom = Rectangle.NO_BORDER;
                }
                if (r == 1)
                {
                    cell.BorderWidthLeft = BorderWidth;
                    cell.BorderWidthBottom = BorderWidth;
                }
                if (r == 2)
                {
                    cell.BorderWidthLeft = Rectangle.NO_BORDER;
                    cell.BorderWidthBottom = Rectangle.NO_BORDER;
                }
                if (r == 3)
                {
                    cell.BorderWidthLeft = Rectangle.NO_BORDER;
                    cell.BorderWidthBottom = BorderWidth;
                }
            }
            else
                cell.Border = Rectangle.NO_BORDER;
            cell.PaddingLeft = PaddingLeft;
            cell.PaddingRight = PaddingRight;
            cell.PaddingTop = PaddingTop;
            cell.PaddingBottom = PaddingBottom;
            row.AddCell(cell);//将单元格添加到表格中
        }
        #endregion

using (FileStream fs = new FileStream(localpath, FileMode.Create))
            {
                using (Document document = new Document(new Rectangle(0, 0, PageSize.A4.Width, PageSize.A4.Height)))
                {
                    PdfWriter pdfWriter = PdfWriter.GetInstance(document, fs);
                    document.Open();
                    BaseFont bsFont = BaseFont.CreateFont("C:/WINDOWS/Fonts/simfang.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
                    Font titleFont = new Font(bsFont, 15, Font.BOLD);
                    Font contentfont = new Font(bsFont, 13, Font.NORMAL);

                    #region   生成托管户划款指令
                    string moneyUpper = CommonFunctions.GetUpper(m.划款金额);
                    string dateStr = (m.划款日期.HasValue ? m.划款日期.Value.ToString("yyyy年MM月dd日") : "");
                    var sb = new System.Text.StringBuilder();
                    string title = m.托管户划款指令表名称 != m.募集户划款指令表名称 ? m.托管户划款指令表名称 : m.托管户划款指令表名称;
                    //设置托管户标题
                    document.Add(new Paragraph(" ", titleFont));
                    document.Add(new Paragraph(title, titleFont) { Alignment = Element.ALIGN_CENTER });
                    document.Add(new Paragraph(" ", contentfont));
                    //设置托管户表头
                    document.Add(new Paragraph($"日期:{dateStr}        ", contentfont) { Alignment = Element.ALIGN_RIGHT });
                    document.Add(new Paragraph(" ", contentfont));
                    //设置托管户表
                    PdfPTable table = new PdfPTable(2);
                    int[] TableWidths = { 45, 45 };//按百分比分配单元格宽带
                    table.SetWidths(TableWidths);
                    table.TotalWidth = 500;//设置绝对宽度
                    table.LockedWidth = true;//使绝对宽度模式生效
                    float BorderWidth = 0.5F;

                    WritePDF.WriteCell(table, contentfont, "付款户名:" + m.托管户户名, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0);
                    WritePDF.WriteCell(table, contentfont, "收款户名:" + m.融资方户名, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                    WritePDF.WriteCell(table, contentfont, "付款账号:" + CommonFunctions.处理银行卡号(m.托管户账号), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0);
                    WritePDF.WriteCell(table, contentfont, "收款账号:" + CommonFunctions.处理银行卡号(m.融资方账号), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                    WritePDF.WriteCell(table, contentfont, "开户行:" + m.托管户开户行, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0, Rowspan: 2);
                    WritePDF.WriteCell(table, contentfont, "开户行:" + m.融资方开户行, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                    WritePDF.WriteCell(table, contentfont, "大额系统支付号:" + m.融资方大额支付号, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                    WritePDF.WriteCell(table, contentfont, "大写金额:人民币" + moneyUpper, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0);
                    WritePDF.WriteCell(table, contentfont, "小写金额(单位:元):¥" + m.划款金额.ToString("c"), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);

                    sb.Clear();
                    int count = 3;
                    sb.AppendLine("资金用途:" + m.托管户资金用途);
                    for (int i = 0; i < count - m.托管户资金用途.Length / 15; i++) sb.AppendLine();
                    WritePDF.WriteCell(table, contentfont, sb.ToString(), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, r: 0);

                    sb.Clear();
                    sb.AppendLine("用款依据:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    WritePDF.WriteCell(table, contentfont, sb.ToString(), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, r: 2);

                    sb.Clear();
                    sb.AppendLine("管理人经办人:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    sb.AppendLine("管理人复核人:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    sb.AppendLine("管理人签发人:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    sb.AppendLine("管理人预留印鉴盖章处:");
                    for (int i = 0; i < count; i++) sb.AppendLine();

                    WritePDF.WriteCell(table, contentfont, sb.ToString(), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, r: 1);
                    sb.Clear();
                    sb.AppendLine("托管人经办人:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    sb.AppendLine("托管人复核人:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    sb.AppendLine("托管人审批人:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    sb.AppendLine("托管人预留印鉴盖章处:");
                    for (int i = 0; i < count; i++) sb.AppendLine();
                    WritePDF.WriteCell(table, contentfont, sb.ToString(), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, r: 3);
                    document.Add(table);
                    #endregion

                    #region  生成募集户划款指令
                    if (m.募集户划款指令表名称.IsNotNullOrWhiteSpace() && m.募集户划款指令模板 == 0)
                    {
                        //恒丰募集户指令模板
                        document.NewPage();
                        string title_mj = m.募集户划款指令表名称;
                        //设置募集户标题
                        document.Add(new Paragraph(" ", titleFont));
                        document.Add(new Paragraph(title_mj, titleFont) { Alignment = Element.ALIGN_CENTER });
                        document.Add(new Paragraph(" ", contentfont));
                        //设置募集户表头
                        document.Add(new Paragraph($"日期:{dateStr}        ", contentfont) { Alignment = Element.ALIGN_RIGHT });
                        document.Add(new Paragraph(" ", contentfont));
                        //设置募集户表
                        PdfPTable table_mj = new PdfPTable(2);
                        int[] TableWidths_mj = { 45, 45 };//按百分比分配单元格宽带
                        table_mj.SetWidths(TableWidths_mj);
                        table_mj.TotalWidth = 500;//设置绝对宽度
                        table_mj.LockedWidth = true;//使绝对宽度模式生效
                        WritePDF.WriteCell(table_mj, contentfont, "付款户名:" + m.募集户户名, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0);
                        WritePDF.WriteCell(table_mj, contentfont, "收款户名:" + m.托管户户名, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                        WritePDF.WriteCell(table_mj, contentfont, "付款账号:" + CommonFunctions.处理银行卡号(m.募集户账号), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0);
                        WritePDF.WriteCell(table_mj, contentfont, "收款账号:" + CommonFunctions.处理银行卡号(m.托管户账号), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                        WritePDF.WriteCell(table_mj, contentfont, "开户行:" + m.募集户开户行, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0);
                        WritePDF.WriteCell(table_mj, contentfont, "开户行:" + m.托管户开户行, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 2);
                        WritePDF.WriteCell(table_mj, contentfont, "付款金额(小写):¥" + m.划款金额.ToString("c"), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0, Colspan: 2);
                        WritePDF.WriteCell(table_mj, contentfont, "付款金额(大写):人民币" + moneyUpper, BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, PaddingBottom: 10, r: 0, Colspan: 2);

                        count = 5;
                        sb = sb.Clear();
                        sb.AppendLine("指令发出人信息栏:");
                        sb.AppendLine("要求到账时间:");
                        sb.AppendLine(string.Format("资金用途及用款依据:{0}", m.募集户资金用途));
                        sb.AppendLine("经办人:");
                        for (int i = 0; i < count; i++) sb.AppendLine();
                        sb.AppendLine("复核人:");
                        for (int i = 0; i < count; i++) sb.AppendLine();
                        sb.AppendLine("预留的有效印章:");
                        for (int i = 0; i < count; i++) sb.AppendLine();
                        WritePDF.WriteCell(table_mj, contentfont, sb.ToString(), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, r: 1);
                        sb.Clear();
                        sb.AppendLine("监督人反馈信息栏:");
                        sb.AppendLine("1、该指令已执行:");
                        sb.AppendLine("2、该指令未执行,原因如下:");
                        for (int i = 0; i < count; i++) sb.AppendLine();
                        sb.AppendLine("经办人:");
                        for (int i = 0; i < count; i++) sb.AppendLine();
                        sb.AppendLine("复核人:");
                        for (int i = 0; i < count; i++) sb.AppendLine();
                        WritePDF.WriteCell(table_mj, contentfont, sb.ToString(), BorderWidth: BorderWidth, HorizontalAlignment: PdfPCell.ALIGN_LEFT, r: 3);
                        WritePDF.WriteCell(table_mj, contentfont, "        重要提示:接此指令后,经审核无误应按照指令条款进行划款。", HorizontalAlignment: PdfPCell.ALIGN_LEFT, Colspan: 2);
                        document.Add(table_mj);

                    }
                    else if (m.募集户划款指令表名称.IsNotNullOrWhiteSpace() && m.募集户划款指令模板 == 1)
                    {
                        //生成中信募集户指令模板 委托付款通知书
                        document.NewPage();
                        title = "委托付款通知书";
                        //设置标题
                        document.Add(new Paragraph(20, title, titleFont) { Alignment = Element.ALIGN_CENTER });
                        document.Add(new Paragraph("划款时间:" + dateStr + "                                            单位:元", contentfont));
                        document.Add(new Paragraph(10, " ", contentfont));
                        PdfPTable row = new PdfPTable(2);
                        int[] TableWidth = { 50, 50 };//按百分比分配单元格宽带
                        row.SetWidths(TableWidth);
                        row.TotalWidth = 500;//设置绝对宽度
                        row.LockedWidth = true;//使绝对宽度模式生效

                        WritePDF.WriteCell(row, contentfont, "监督协议编号:SH-SM-SF0046", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 2, 0, 0, 0, 10, 0, 1);
                        WritePDF.WriteCell(row, contentfont, "付款户名:共青城祥腾兴投资管理合伙企业(有限合伙)", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 0, 1);
                        WritePDF.WriteCell(row, contentfont, "收款户名:共青城祥腾兴投资管理合伙企业(有限合伙)", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 2, 1);
                        WritePDF.WriteCell(row, contentfont, "付款账号:9050301201900037720118", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 0, 1);
                        WritePDF.WriteCell(row, contentfont, "收款账号:8111401013600363037", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 2, 1);
                        WritePDF.WriteCell(row, contentfont, "开户行:温州银行上海徐汇支行", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 0, 1);
                        WritePDF.WriteCell(row, contentfont, "开户行:中信银行天津分行营业部", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 2, 1);
                        WritePDF.WriteCell(row, contentfont, "大写金额:" + moneyUpper, BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 0, 1);
                        //祥腾兴募集转托管的指令是没有千位符号 别的所有的指令都有的
                        WritePDF.WriteCell(row, contentfont, "小写金额:¥" + m.划款金额, BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 2, 1);

                        sb = new StringBuilder();
                        sb.AppendLine(" 用途及备注:");
                        sb.AppendLine(" " + m.募集户资金用途);
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine();
                        WritePDF.WriteCell(row, contentfont, sb.ToString(), BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 0, 1);

                        sb = new StringBuilder();
                        sb.AppendLine(" 签发人:");
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine(" 预留印章:");
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine("             年      月      日             ");
                        sb.AppendLine();
                        WritePDF.WriteCell(row, contentfont, sb.ToString(), BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_LEFT, 0, 0, 0, 0, 10, 2, 1);

                        WritePDF.WriteCell(row, contentfont, "监督人指令执行情况", BorderWidth, PdfPCell.ALIGN_MIDDLE, PdfPCell.ALIGN_CENTER, 2, 0, 0, 0, 10, 0, 1);

                        sb = new StringBuilder();
                        sb.AppendLine(" 指令处理岗办理审批意见:");
                        sb.AppendLine();
                        sb.AppendLine(" 经办:");
                        sb.AppendLine();
                        sb.AppendLine(" 复核:");
                        sb.AppendLine();
                        sb.AppendLine(" 负责人:");
                        sb.AppendLine();
                        sb.AppendLine();
                        sb.AppendLine("                                                        年      月      日             ");
                        sb.AppendLine();
                        WritePDF.WriteCell(row, contentfont, sb.ToString(), BorderWidth, PdfPCell.ALIGN_LEFT, PdfPCell.ALIGN_LEFT, 4, 0, 0, 0, 10, 1, 1);
                        document.Add(row);//将表格添加到pdf文档中
                        #endregion

                        #region 临开函
                        document.NewPage();
                        title = "关于共青城祥腾兴投资管理合伙企业(有限合伙)新增临时开放日的公告";
                        //设置标题
                        document.Add(new Paragraph(80, title, titleFont) { Alignment = Element.ALIGN_CENTER });
                        document.Add(new Paragraph(40, " ", contentfont));
                        document.Add(new Paragraph("尊敬的客户:", contentfont) { IndentationLeft = 50 });

                        var 划款日前一工作日 = CommonFunctions.跳过法定节假日加(db, m.划款日期.Value, -1);
                        var Para1 = new Paragraph(20);
                        Para1.IndentationLeft = 50;
                        Para1.IndentationRight = 50;
                        Para1.Font = contentfont;
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("    根据《共青城祥腾兴投资管理合伙企业(有限合伙)》合伙协议的约定,本管理人现根据基金运作情况的需要,现新增"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(划款日前一工作日.Year.ToString()));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("年"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(划款日前一工作日.Month.ToString()));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("月"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(划款日前一工作日.Day.ToString()));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("日至"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(划款日前一工作日.Year.ToString()));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("年"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(划款日前一工作日.Month.ToString()));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("月"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(划款日前一工作日.Day.ToString()));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("日为本基金的临时开放日,临时开放日受理基金"));
                        Para1.Add(WritePDF.CreateSongtiUnderLineChunk(" 申购 "));
                        Para1.Add(WritePDF.CreateSongtiNomalChunk("。"));
                        document.Add(Para1);

                        document.Add(new Paragraph("    此次临时开放日后,基金开放日仍按基金合同原先的约定执行。", contentfont) { IndentationLeft = 50 });
                        document.Add(new Paragraph("    特此公告。", contentfont) { IndentationLeft = 50 });
                        document.Add(new Paragraph(100, " "));
                        document.Add(new Paragraph("上海祥乾投资管理有限公司  ", contentfont) { Alignment = Element.ALIGN_RIGHT });
                        document.Add(new Paragraph(划款日前一工作日.ToString("yyyy年MM月dd日") + "  ", contentfont) { Alignment = Element.ALIGN_RIGHT });
                    }
                    #endregion
                }
            }

生成之后长这样

 

 

Free Spire.PDF for .NET 是 Spire.PDF for .NET 的免费版本,无需购买即可用于个人或商业用途。使用该组件,程序员可以 在.NET 程序中创建、读取、写入、编辑和操作 PDF 文档。这个控件能支持的功能十分全面,例如文档安全性设置(电子签名),提取 PDF 文本、附件、图片,PDF 合并和拆分,更新 Metadata,设置 Section,绘制图形、插入图片、表格制作和加工、导入数据等等。除此以外,Spire.PDF 还可以将 TXT 文本、图片、HTML 高质量地转换为 PDF 文件格式。 主要功能如下: 1.高质量的文档转换。Free Spire.PDF for .NET 支持 PDF 到 Word、XPS、SVG、EMF、Text 和图片(EMF、JPG、PNG、BMP、TIFF)的格式转换。也支持从 XML、HTML、RTF、XPS、Text、图片等格式生成 PDF 文档。 2.文档操作及域功能。支持合并、拆分 PDF 文档,在原有的 PDF 文档页添加覆盖页。同时,Spire.PDF 提供导入、邮戳、小册子功能,以及帮助用户从数据库读取数据并填充到域的域填写功能。 3. 安全性设置。用户可以通过设置密码和数字签名来保护 PDF 文档。用户密码和所有者密码可以确定加密的 PDF 文档的可读性、可修改性、是否可打印等有选择性的限制。与此同时,数字签名作为一个更有效的方法,可以应用于维护和对PDF文档进行身份验证。 4.数据提取。支持快速高效地从 PDF 文档提取图片、文本、PDF 分页,以及附件。 5.文件属性设置。支持对 Metadata、文件属性、页面方向、页面大小进行设置。其中文件属性包括文件限制(打印、页面提取、加评论等方面的权限限制)以及文件描述属性(文件名称、作者、主题、关键字等)。使用 Spire.PDF for .NET,用户还可以根据自己阅读喜好设定默认打开页码,分页模式,缩放比例和打印缩放,等等。 6.其他功能。 支持多种语言,支持字体格式、对齐方式设置。 绘制文字,图片,图形。 支持添加图层,透明图像,Color Space,条形码到 PDF。 支持 PDF/A-1b、PDF/x1a:2001 格式。 添加梯状图形和矢量图像到指定位置。 添加并格式化表格。 插入交互元素,例如添加自定义的 Annotation、Action、JavaScript、附件、书签等。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值