using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.AutomaticFields;
using Spire.Pdf.Graphics;
using Spire.Pdf.Grid;
namespace PDFCreator
{
class PDF
{
public static void Create()
{
PdfDocument doc = CreateDocument("出现信息", "标题:张三");
PdfFontBase fontInfo = new PdfTrueTypeFont(new Font("宋体", 9f, FontStyle.Regular), true);
PdfFontBase fontSmallTitle = new PdfTrueTypeFont(new Font("宋体", 9f, FontStyle.Bold), true);
PdfFontBase fontBigTitle = new PdfTrueTypeFont(new Font("宋体", 15f, FontStyle.Bold), true);
List listGrids = new List();
Dictionary dictCellAlignment = new Dictionary();
Random random = new Random();
for (int num = 0; num < 10; num++)
{
PdfGrid grid = CreateGrid(7);
listGrids.Add(grid);
List listRows = new List();
PdfGridRow row1 = grid.Rows.Add();
PdfGridRow row2 = grid.Rows.Add();
listRows.Add(row1);
listRows.Add(row2);
row1.Cells[0].ColumnSpan = 2; //从0行合并行单元格
row1.Cells[0].RowSpan = 2; //从0行合并行单元格
PdfGridCellTextAndStyleList lst = new PdfGridCellTextAndStyleList();
PdfGridCellTextAndStyle pdfText = new PdfGridCellTextAndStyle();
pdfText.Text = "张三";
pdfText.Font = fontInfo;
pdfText.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
lst.List.Add(pdfText);
Image img = Properties.Resources.logo;
PdfGridCellTextAndStyle pdfImg = new PdfGridCellTextAndStyle();
pdfImg.Image = PdfImage.FromImage(img);
pdfImg.ImageNewline = true;
pdfImg.ImageSize = new SizeF(60, 45);
pdfImg.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Bottom);
lst.List.Add(pdfImg);
row1.Cells[0].Value = lst;
row1.Cells[2].ColumnSpan = 5;
row1.Cells[2].Value = "籍贯:广东深圳";
row1.Cells[2].Style.Font = fontInfo;
dictCellAlignment[row1.Cells[2]] = PdfTextAlignment.Left;
row2.Cells[2].ColumnSpan = 3;
row2.Cells[2].Value = "性别:男";
row2.Cells[2].Style.Font = fontInfo;
row2.Cells[5].ColumnSpan = 2;
row2.Cells[5].Value = "年龄:30";
row2.Cells[5].Style.Font = fontInfo;
PdfGridRow rowHead = grid.Rows.Add();
rowHead.Cells[0].Value = "序号";
rowHead.Cells[1].Value = "地址";
rowHead.Cells[2].Value = "到达时间";
rowHead.Cells[3].Value = "到达方式";
rowHead.Cells[4].Value = "离开时间";
rowHead.Cells[5].Value = "离开方式";
rowHead.Cells[6].Value = "合计天数";
rowHead.Style.BackgroundBrush = PdfBrushes.Gainsboro;
rowHead.Style.Font = fontInfo;
listRows.Add(rowHead);
List