itextsharp生成pdf分页
stringfilename=DateTime.Now.ToString("yyyyMMddHHmmss").ToString()+".pdf";
floatw=PageSize.A4.Width;
floath=PageSize.A4.Height;
Rectanglerect=newRectangle(0,0,w,3*h);
Documentdocument=newDocument(rect);
PdfWriterwriter=PdfWriter.GetInstance(document,newFileStream(Server.MapPath(filename),FileMode.Create));
Rectanglecrop=newRectangle(0,2*h,w,3*h);
writer.CropBoxSize=crop;
document.Open();
PdfContentBytecontent=writer.DirectContent;
PdfTemplatetemplate=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=newRectangle(0,h,w,2*h);
writer.CropBoxSize=crop;
document.NewPage();
content.AddTemplate(template,1,0,0,-1,0,rect.Height);
crop=newRectangle(0,0,w,h);
writer.CropBoxSize=crop;
document.NewPage();
content.AddTemplate(template,1,0,0,-1,0,rect.Height);
document.Close();
附件:http://down.51cto.com/data/2363094声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。