itextsharp生成pdf分页
string filename = DateTime.Now.ToString("yyyyMMddHHmmss").ToString() + ".pdf";
站在用户的角度思考问题,与客户深入沟通,找到埇桥区网站设计与埇桥区网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、成都网站设计、成都外贸网站建设、企业官网、英文网站、手机端网站、网站推广、域名注册、雅安服务器托管、企业邮箱。业务覆盖埇桥区地区。
float w = PageSize.A4.Width;
float h = PageSize.A4.Height;
Rectangle rect = new Rectangle(0, 0, w, 3 * h);
Document document = new Document(rect);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(Server.MapPath(filename), FileMode.Create));
Rectangle crop = new Rectangle(0, 2 * h, w, 3 * h);
writer.CropBoxSize = crop;
document.Open();
PdfContentByte content = writer.DirectContent;
PdfTemplate template = content.CreateTemplate(rect.Width, rect.Height);
template.SaveState();
template.SetColorFill(Color.RED);
template.Rectangle(0, 0, w, h);
template.FillStroke();
template.RestoreState();
template.SaveState();
template.SetColorFill(Color.BLUE);
template.Rectangle(0, h, w, h);
template.FillStroke();
template.RestoreState();
template.SaveState();
template.SetColorFill(Color.BLACK);
template.Rectangle(0, 2 * h, w, h/2 );
template.FillStroke();
template.RestoreState();
content.AddTemplate(template, 1, 0, 0, -1, 0, rect.Height);
crop = new Rectangle(0, h, w, 2 * h);
writer.CropBoxSize = crop;
document.NewPage();
content.AddTemplate(template, 1, 0, 0, -1, 0, rect.Height);
crop = new Rectangle(0, 0, w, h);
writer.CropBoxSize = crop;
document.NewPage();
content.AddTemplate(template, 1, 0, 0, -1, 0, rect.Height);
document.Close();
本文题目:itextsharp生成pdf分页
本文网址:http://myzitong.com/article/jhhoee.html