[code]
Result rs = new Result();
var DateResult = GetMonthReportService(condition);
PdfDocument doc = new PdfDocument();
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
PdfPageBase page = doc.Pages.Add(PdfPageSize.A2, margin);
float y = 10;
PdfBrush brush1 = PdfBrushes.Black;
PdfCjkStandardFont font = new PdfCjkStandardFont(PdfCjkFontFamily.SinoTypeSongLight, 20f);
PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
page.Canvas.DrawString(condition.title, font, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
y = y + font.MeasureString(condition.title, format1).Height;
y = y + 5;
String[][] dataSource
= new String[DateResult.Rows.Count][];
for (int i = 0; i < DateResult.Rows.Count; i++)
{
var r = DateResult.Rows[i];
object[] objs = r.ItemArray;
dataSource[i] = r.ItemArray.Select(o => o.ToString()).ToArray(); ;
}
PdfTable table = new PdfTable();
table.Style.CellPadding = 2;
table.Style.HeaderSource = PdfHeaderSource.Rows;
table.Style.HeaderRowCount = 1;
table.Style.ShowHeader = true;
table.DataSource = dataSource;
//创建PdfTrueTypeFont支持中文字体
PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(new Font("微软雅黑", 18f), true);
//应用字体到PDF table
table.Style.AlternateStyle.Font = trueTypeFont;
table.Style.DefaultStyle.Font = trueTypeFont;
table.Style.HeaderStyle.Font = trueTypeFont;
PdfLayoutResult result = table.Draw(page, new PointF(0, y));
y = y + result.Bounds.Height + 5;
PdfBrush brush2 = PdfBrushes.Gray;
page.Canvas.DrawString(String.Format("* {0} countries in the list.", DateResult.Rows.Count - 1), trueTypeFont, new PdfSolidBrush(Color.Black), 5, y);
//Save pdf file.
doc.SaveToFile(@"d:\FirstPDF.pdf", FileFormat.PDF);
doc.Close();
//System.Diagnostics.Process.Start(@"d:\FirstPDF.pdf");
rs.success = true;
rs.data.Add("data", "ok");
return rs;
怎么去掉这两个印记 :第一个印记 在pdf文件头部出现 Evaluation Warning : The document was created with Spire.PDF for .NET.
第二个印记 * 209 countries in the list