Как заставить таблицу продолжать запись на первой странице, чтобы не переходить на следующую страницу? Я использую SplitLate = false;
, но он по-прежнему не работает.
введите описание изображения здесь
Вот мой код контроллера
Document pdfDoc = new Document();
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.SetPageSize(PageSize.A4);
pdfDoc.SetMargins(71, 59, 63, 58); //( point marginLeft, point marginRight, point marginTop, point marginBottom )
pdfDoc.Open();
var newpage = false;
if (newpage == true)
{
pdfDoc.NewPage();
}
newpage = true;
#region Title
Chunk chunk = new Chunk("Tangerang Selatan, ", FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK));
Paragraph para = new Paragraph();
para.Add(chunk);
para.Alignment = Element.ALIGN_LEFT;
para.SpacingBefore = 50f;
para.SpacingAfter = 20f;
pdfDoc.Add(para);
#endregion
#region Heading
//Table 1
PdfPTable table = new PdfPTable(4);
float[] widths = new float[] { 25f, 5f, 17f, 153f };
table.SetWidths(widths);
table.WidthPercentage = 100;
table.HorizontalAlignment = Element.ALIGN_CENTER;
table.SpacingBefore = 10f;
table.SpacingAfter = 20f;
//Cell Row 1
PdfPCell cell = new PdfPCell();
cell = new PdfPCell(new Phrase(String.Format("Nomor"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(":"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(data.Bab.Kelompok.Singkatan + "/ /"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
//Cell Row 2
cell = new PdfPCell(new Phrase(String.Format("Kepada"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(":"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("Kelompok PGO"), FontFactory.GetFont("Arial", 11, Font.BOLD, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
//Cell Row 3
cell = new PdfPCell(new Phrase(String.Format("Dari"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(":"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("Kelompok " + data.Bab.Kelompok.Nama + " (" + data.Bab.Kelompok.Singkatan + ")"), FontFactory.GetFont("Arial", 11, Font.BOLD, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table.AddCell(cell);
//Cell Row 4
cell = new PdfPCell(new Phrase(String.Format("Hal"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(":"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("Pengajuan Update Pedoman Perusahaan (PP) " + data.Bab.Book.NamaBuku + " Bab " + data.Bab.NamaBab), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
table.AddCell(cell);
//Cell Row 5
cell = new PdfPCell(new Phrase(String.Format("Lamp"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(":"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("1 (satu) Set"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
pdfDoc.Add(table);
#endregion
#region Isi
//Paragraf Isi Pertama
chunk = new Chunk("Menunjuk perihal pada pokok nota intern tersebut diatas, bersama ini kami sampaikan beberapa hal sebagai berikut:", FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK));
para = new Paragraph();
para.Add(chunk);
para.Alignment = Element.ALIGN_JUSTIFIED;
pdfDoc.Add(para);
#region Table Poin 1 - 2
table = new PdfPTable(3);
widths = new float[] { 7f, 7f, 186f };
table.SetWidths(widths);
table.WidthPercentage = 100;
table.SpacingBefore = 10f;
table.HorizontalAlignment = Element.ALIGN_CENTER;
#region No 1
//Cell 1-1
cell = new PdfPCell(new Phrase(String.Format("1."), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
table.AddCell(cell);
//Cell 1-2
cell = new PdfPCell(new Phrase(String.Format("Telah dilakukan review dokumen Pedoman Perusahaan (PP) " + data.Bab.Book.NamaBuku + " Bab " + data.Bab.NamaBab + ", untuk selanjutnya dilakukan update pada dokumen PP sebagai berikut:"), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
table.AddCell(cell);
//Cell 2-1
cell = new PdfPCell(new Phrase(String.Format(""), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
table.AddCell(cell);
#region Table No 1
PdfPTable table2 = new PdfPTable(5);
//widths = new float[] { 7f, 38f, 38f, 39f, 39f, 39f };
widths = new float[] { 50f, 50f, 50f, 50f, 110f };
table2.SetWidths(widths);
table2.WidthPercentage = 100;
table2.HorizontalAlignment = Element.ALIGN_CENTER;
#region Header Tabel No 1
cell = new PdfPCell(new Phrase(String.Format("BUKU PP"), FontFactory.GetFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("BAB PP"), FontFactory.GetFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("SUB BAB PP"), FontFactory.GetFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("SUB SUB BAB PP"), FontFactory.GetFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format("KETERANGAN " + data.Updating.Nama.ToUpper()), FontFactory.GetFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
#endregion
#region Isi Tabel No 1
if (data.SubBabReportVM != null)
{
cell = new PdfPCell(new Phrase(String.Format(data.Bab.Book.NamaBuku), FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK)));
cell.Rowspan = data.RowSummary;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
cell = new PdfPCell(new Phrase(String.Format(data.Bab.NamaBab), FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK)));
cell.Rowspan = data.RowSummary;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
foreach (var data2 in data.SubBabReportVM)
{
cell = new PdfPCell(new Phrase(String.Format(data2.SubBab.NamaSubBab), FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK)));
cell.Rowspan = data2.RowSubbab;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
foreach (var data3 in data2.SubSubBabReportVM)
{
cell = new PdfPCell(new Phrase(String.Format(data3.SubSubBab.NamaSubSubBab), FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK)));
cell.Rowspan = data3.RowSubSubbab;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
cell.Padding = 5f;
table2.AddCell(cell);
foreach (var data4 in data3.SummaryTransaction)
{
cell = new PdfPCell(new Phrase(String.Format(data4.Penjelasan), FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK)));
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
cell.VerticalAlignment = Element.ALIGN_JUSTIFIED;
cell.Padding = 5f;
table2.AddCell(cell);
}
}
}
}
else
{
cell = new PdfPCell(new Phrase(String.Format("Data Tidak tersedia"), FontFactory.GetFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
cell.Colspan = 5;
cell.Rowspan = 3;
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
table2.AddCell(cell);
}
#endregion
table2.HeaderRows = 1;
table2.SplitLate = false;
#endregion
//Cell 2-2
cell = new PdfPCell(table2);
cell.Border = 0;
cell.Colspan = 2;
cell.PaddingTop = 10f;
cell.PaddingBottom = 10f;
table.AddCell(cell);
#endregion
#region No 2
//Cell 1-1
cell = new PdfPCell(new Phrase(String.Format("2."), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
table.AddCell(cell);
//Cell 1-2
cell = new PdfPCell(new Phrase(String.Format("Sehubungan dengan hal tersebut di atas, terlampir disampaikan draft dokumen dan summary update Pedoman Perusahaan untuk diverifikasi sebelum dilakukan upload dan sertifikasi pada aplikasi BNI e-PP."), FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK)));
cell.Border = 0;
cell.Colspan = 2;
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
table.AddCell(cell);
#endregion
pdfDoc.Add(table);
#endregion
//Paragraf Isi Kedua
chunk = new Chunk("Demikian kami sampaikan, atas perhatian dan kerjasamanya diucapkan terima kasih.", FontFactory.GetFont("Arial", 11, Font.NORMAL, BaseColor.BLACK));
para = new Paragraph();
para.Add(chunk);
para.Alignment = Element.ALIGN_LEFT;
para.SpacingBefore = 10f;
para.SpacingAfter = 20f;
pdfDoc.Add(para);
//Footer
chunk = new Chunk("Kelompok " + data.Bab.Kelompok.Nama, FontFactory.GetFont("Arial", 11, Font.BOLD, BaseColor.BLACK));
para = new Paragraph();
para.Add(chunk);
para.Alignment = Element.ALIGN_LEFT;
para.SpacingBefore = 10f;
pdfDoc.Add(para);
#endregion
pdfWriter.CloseStream = false;
pdfDoc.Close();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Nota Intern Pengajuan Update PP " + data.Bab.NamaBab + ".pdf");
//Response.AddHeader("content-disposition", "attachment;filename=Nota Intern Persetujuan Update PP.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();