string filename = DateTime.Now.ToString("yyyyMMddHHmmss").ToString() + ".pdf";ide
float w = PageSize.A4.Width;
float h = PageSize.A4.Height;string
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));it
Rectangle crop = new Rectangle(0, 2 * h, w, 3 * h);
writer.CropBoxSize = crop;class
document.Open();pdf
PdfContentByte content = writer.DirectContent;file
PdfTemplate template = content.CreateTemplate(rect.Width, rect.Height);
template.SaveState();
template.SetColorFill(Color.RED);
template.Rectangle(0, 0, w, h);
template.FillStroke();
template.RestoreState();float
template.SaveState();
template.SetColorFill(Color.BLUE);
template.Rectangle(0, h, w, h);
template.FillStroke();
template.RestoreState();im
template.SaveState();
template.SetColorFill(Color.BLACK);
template.Rectangle(0, 2 * h, w, h/2 );
template.FillStroke();
template.RestoreState();di
content.AddTemplate(template, 1, 0, 0, -1, 0, rect.Height);view
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();