资源简介
Aspose.Pdf生成pdf例子,可以参考下
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Aspose.Pdf.Generator;
using Aspose.BarCode;
using System.Drawing;
namespace Aspose_Test.App_Code
{
public class Print_test
{
///
/// 生成pdf
///
///
public static void CreatePdf(string dataDir)
{
Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
TextInfo text_info = new TextInfo() { FontName = “微软雅黑“ FontSize=10};
Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();
sec1.PageInfo.Margin.Left = 40;
sec1.PageInfo.Margin.Right = 40;
sec1.PageInfo.Margin.Bottom = 40;
#region 头部
Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
sec1.OddHeader = header;
sec1.EvenHeader = header;
header.Margin.Top = 20;
Aspose.Pdf.Generator.Table tab_header = new Aspose.Pdf.Generator.Table();
header.Paragraphs.Add(tab_header);
tab_header.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All 0F);
tab_header.ColumnWidths = “300 220“;
tab_header.VerticalAlignment = VerticalAlignmentType.Center;
Aspose.Pdf.Generator.Row row_header0 = tab_header.Rows.Add();
row_header0.Cells.Add(“ST103“ text_info);
SetCell(row_header0.Cells[0] 2 AlignmentType.Left VerticalAlignmentType.Center true);
row_header0.FixedRowHeight = 20;
Aspose.Pdf.Generator.Row row_header1 = tab_header.Rows.Add();
row_header1.Cells.Add(“装订线上方3.5cm留白,禁止书写,禁止粘贴票据。请不要把多张申请单粘贴在一起“ text_info);
SetCell(row_header1.Cells[0] 2 AlignmentType.Center VerticalAlignmentType.Center false);
row_header1.FixedRowHeight = 20;
Aspose.Pdf.Generator.Row row_header2 = tab_header.Rows.Add();
row_header2.Cells.Add(“------------------------装----------------------订-----------------------线-----------------------“ text_info);
SetCell(row_header2.Cells[0] 2 AlignmentType.Center VerticalAlignmentType.Center false);
row_header2.FixedRowHeight = 20;
Aspose.Pdf.Generator.Row row_header3 = tab_header.Rows.Add();
row_header3.Cells.Add(“申请单“ text_info);
SetCell(row_header3.Cells[0] 0 AlignmentType.Center VerticalAlignmentType.Center true);
Aspose.Pdf.Generator.Cell cell = row_header3.Cells.Add();
CreateBarCode(cell“ABCD10342DFA56744“);
Aspose.Pdf.Generator.Row row_header4 = tab_header.Rows.Add();
row_header4.FixedRowHeight = 20;
row_header4.Cells.Add(“请投递于A箱中“ text_info);
- 上一篇:C#对TXT读写
- 下一篇:C#图书管理系统(功能齐全,包括借还书,超期罚款等功能)
评论
共有 条评论