我想根据我的记录创建动态 PDF 文档页面。请帮我。
我想每页打印 3 条记录。
string[] collection = {
"vivek", "kashyap", "viral", "darshit", "arpit", "sameer", "vanraj"
};
PdfDocument pdfDoc = new PdfDocument();
int records = collection.Length;
int perpage = 3;
int pages = (int)Math.Ceiling((double)records / (double)perpage);
for (int p = 0; p < pages; p++)
{
PdfPage pdfPage = new PdfPage();
pdfPage.Size = PageSize.Letter;
pdfDoc.Pages.Add(pdfPage);
XFont NormalFont = new XFont("Helvetica", 10, XFontStyle.Regular);
using (var pdfGfx = XGraphics.FromPdfPage(pdfPage))
{
for (int i = 0,next = 100; i < collection.Length; i++)
{
pdfGfx.DrawString( "Name : " + collection[i].ToString()
, NormalFont, XBrushes.Black, 55, next
, XStringFormats.Default);
next += 20;
}
}
}