We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Need support about aspose pdf

how to create dinamic row table

Hi Ahmad,


Thanks for contacting support.

From your above requirement, my understanding is that you need to create table with certain number of rows which can be provided at run-time Or you have a requirement to create a PDF file with some button or control in resultant PDF file which can be pressed and a table with certain number of rows can be added/placed inside PDF file. Please share some details so we may reply accordingly.

However in case you simply need to create a PDF file with table Working with Tables.

Hy Nayyer


thanks for respond…

table have been created but… i have proble if have many data
table just in first page so not all data rendering

how to render the table data continues to next page

this my code :

pdfReport = new Pdf();
pdfReport.IsLandscape = true;

pdfReport.IsTruetypeFontMapCached = true;
pdfReport.TruetypeFontMapStream = fontMap;

//set ukuran pdf
pdfReport.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;
pdfReport.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.A4Width;

//set margin
pdfReport.PageSetup.Margin.Left = 25;
pdfReport.PageSetup.Margin.Right = 10;

//Create the section in the Pdf object
Section sec1 = pdfReport.Sections.Add();


//set title
Aspose.Pdf.Generator.Table tabTitle = new Aspose.Pdf.Generator.Table();
sec1.Paragraphs.Add(tabTitle);
tabTitle.ColumnWidths = “790”;
tabTitle.PositioningType = PositioningType.ColumnRelative;
Aspose.Pdf.Generator.Row rowTitle = tabTitle.Rows.Add();
rowTitle.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
rowTitle.DefaultCellTextInfo.FontSize = 20;
rowTitle.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
rowTitle.Cells.Add(“LAPORAN PERJANJIAN”);
//end of set title

//set date
Aspose.Pdf.Generator.Table tabDate = new Aspose.Pdf.Generator.Table();
tabDate.Margin.Top = 50;
sec1.Paragraphs.Add(tabDate);
tabDate.ColumnWidths = “790”;
tabDate.PositioningType = PositioningType.ColumnRelative;
Aspose.Pdf.Generator.Row rowDate = tabDate.Rows.Add();
rowDate.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
rowDate.DefaultCellTextInfo.FontSize = 15;
rowDate.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
rowDate.Cells.Add(reportDate);
//end of set date


//Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

//margin table
tab1.Margin.Top = 100;

//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);

//Set with column widths of the table
tab1.ColumnWidths = “100 100 70 100 100 70 70 100 80”;
tab1.PositioningType = PositioningType.ColumnRelative;

//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

//Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);


//ini baris judul
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.BackgroundColor = new Aspose.Pdf.Generator.Color("#F538FF");
row1.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
row1.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

row1.Cells.Add(“Nomor Perjanjian”);
row1.Cells.Add(“Judul Perjanjian”);
row1.Cells.Add(“Jenis”);
row1.Cells.Add(“Tanggal Perjanjian”);
row1.Cells.Add(“Tanggal Penyampaian”);
row1.Cells.Add(“Pihak Ketiga”);
row1.Cells.Add(“Harga”);
row1.Cells.Add(“Jangka Waktu”);
row1.Cells.Add(“Keterangan”);

string jenis;
string tanggalPenyampaianPerjanjian=" - “;
string tanggalPerjanjian=”";
string pihakKetiga=" - “;
string harga=” - “;
string jangkaWaktu=” - “;
string keterangan=”";


for(int i=0; i < 100; i++)
{

jenis = data.JenisDokumen.ToString();
jenis = jenis.Insert(10, " “);
jenis = jenis.Insert(16, " “);

if (data.TanggalKirimRancanganPerjanjian.HasValue)
tanggalPenyampaianPerjanjian = data.TanggalKirimRancanganPerjanjian.Value.ToString(“dd/MM/yyyy”);

if (data.TanggalTerbitRancanganPerjanjian.HasValue)
tanggalPerjanjian = data.TanggalTerbitRancanganPerjanjian.Value.ToString(“dd/MM/yyyy”);


pihakKetiga = data.PerusahaanTerkait;


if (data.BiayaPerjanjian.HasValue)
harga = “Rp. " + data.BiayaPerjanjian.Value.ToString(”#,##0.00”);

if (data.JangkaWaktuPerjanjianAwal.HasValue && data.JangkaWaktuPerjanjianAkhir.HasValue)
jangkaWaktu = ((data.JangkaWaktuPerjanjianAkhir.Value - data.JangkaWaktuPerjanjianAwal.Value).TotalDays).ToString() + " Hari”;

keterangan = data.Keterangan;



Aspose.Pdf.Generator.Row rowTable = tab1.Rows.Add();
rowTable.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
rowTable.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
rowTable.Cells.Add(“content 1”);
rowTable.Cells.Add(“content 2”);
rowTable.Cells.Add(“content 3”);
rowTable.Cells.Add(“content 4”);
rowTable.Cells.Add(“content 5”);
rowTable.Cells.Add(“content 6”);
rowTable.Cells.Add(“content 7”);
rowTable.Cells.Add(“content 8”);
rowTable.Cells.Add(“content 9”);

}

thanks
Hy Nayyer

thanks for respond...

table have been created but.. i have proble if have many data
table just in first page so not all data rendering

how to render the table data continues to next page

this my code :

pdfReport = new Pdf();
pdfReport.IsLandscape = true;

pdfReport.IsTruetypeFontMapCached = true;
pdfReport.TruetypeFontMapStream = fontMap;

//set ukuran pdf
pdfReport.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;
pdfReport.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.A4Width;

//set margin
pdfReport.PageSetup.Margin.Left = 25;
pdfReport.PageSetup.Margin.Right = 10;

//Create the section in the Pdf object
Section sec1 = pdfReport.Sections.Add();


//set title
Aspose.Pdf.Generator.Table tabTitle = new Aspose.Pdf.Generator.Table();
sec1.Paragraphs.Add(tabTitle);
tabTitle.ColumnWidths = "790";
tabTitle.PositioningType = PositioningType.ColumnRelative;
Aspose.Pdf.Generator.Row rowTitle = tabTitle.Rows.Add();
rowTitle.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
rowTitle.DefaultCellTextInfo.FontSize = 20;
rowTitle.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
rowTitle.Cells.Add("LAPORAN PERJANJIAN");
//end of set title

//set date
Aspose.Pdf.Generator.Table tabDate = new Aspose.Pdf.Generator.Table();
tabDate.Margin.Top = 50;
sec1.Paragraphs.Add(tabDate);
tabDate.ColumnWidths = "790";
tabDate.PositioningType = PositioningType.ColumnRelative;
Aspose.Pdf.Generator.Row rowDate = tabDate.Rows.Add();
rowDate.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
rowDate.DefaultCellTextInfo.FontSize = 15;
rowDate.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
rowDate.Cells.Add(reportDate);
//end of set date


//Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

//margin table
tab1.Margin.Top = 100;

//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);

//Set with column widths of the table
tab1.ColumnWidths = "100 100 70 100 100 70 70 100 80";
tab1.PositioningType = PositioningType.ColumnRelative;

//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

//Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);


//ini baris judul
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.BackgroundColor = new Aspose.Pdf.Generator.Color("#F538FF");
row1.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
row1.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

row1.Cells.Add("Nomor Perjanjian");
row1.Cells.Add("Judul Perjanjian");
row1.Cells.Add("Jenis");
row1.Cells.Add("Tanggal Perjanjian");
row1.Cells.Add("Tanggal Penyampaian");
row1.Cells.Add("Pihak Ketiga");
row1.Cells.Add("Harga");
row1.Cells.Add("Jangka Waktu");
row1.Cells.Add("Keterangan");

for(int i=0; i < 100; i++)
{

Aspose.Pdf.Generator.Row rowTable = tab1.Rows.Add();
rowTable.DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
rowTable.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
rowTable.Cells.Add("content 1");
rowTable.Cells.Add("content 2");
rowTable.Cells.Add("content 3");
rowTable.Cells.Add("content 4");
rowTable.Cells.Add("content 5");
rowTable.Cells.Add("content 6");
rowTable.Cells.Add("content 7");
rowTable.Cells.Add("content 8");
rowTable.Cells.Add("content 9");

}

thanks

Hi Ahmad,


Thanks for sharing the details.

I have tested the scenario and have observed the same issue. However for the sake of correction, I would suggest you to please try using Aspose.Pdf namespace. Please take a look over following code snippet. You may correct the formatting of table as per your requirements.

[C#]

Document doc = new
Document();<o:p></o:p>

doc.Pages.Add();

doc.Pages[1].PageInfo.IsLandscape = true;

// Pdf pdfReport = new Pdf();

// pdfReport.IsLandscape = true;

// pdfReport.IsTruetypeFontMapCached = true;

//pdfReport.TruetypeFontMapStream = fontMap;

doc.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;

doc.PageInfo.Width= Aspose.Pdf.PageSize.A4.Width;

//set ukuran pdf

// pdfReport.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;

// pdfReport.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.A4Width;

doc.PageInfo.Margin.Left = 25;

doc.PageInfo.Margin.Right = 25;

//set margin

// pdfReport.PageSetup.Margin.Left = 25;

// pdfReport.PageSetup.Margin.Right = 10;

//Create the section in the Pdf object

// Section sec1 = pdfReport.Sections.Add();

//set title

Aspose.Pdf.Table tabTitle = new Aspose.Pdf.Table();

doc.Pages[1].Paragraphs.Add(tabTitle);

// sec1.Paragraphs.Add(tabTitle);

tabTitle.ColumnWidths = "790";

// tabTitle. PositioningType = PositioningType.ColumnRelative;

Aspose.Pdf.Row rowTitle = tabTitle.Rows.Add();

//rowTitle.DefaultCellTextState.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

//rowTitle.DefaultCellTextState.FontSize = 20;

// rowTitle.DefaultCe .VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

rowTitle.Cells.Add("LAPORAN PERJANJIAN");

//end of set title

//set date

Aspose.Pdf.Table tabDate = new Aspose.Pdf.Table();

tabDate.Margin.Top = 50;

doc.Pages[1].Paragraphs.Add(tabDate);

//sec1.Paragraphs.Add(tabDate);

tabDate.ColumnWidths = "790";

// tabDate.PositioningType = PositioningType.ColumnRelative;

Aspose.Pdf.Row rowDate = tabDate.Rows.Add();

// rowDate.DefaultCellTextState.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;

// rowDate.DefaultCellTextState.FontSize= 15;

// rowDate.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

rowDate.Cells.Add(""+DateTime.Now);

//end of set date

//Instantiate a table object

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

//margin table

tab1.Margin.Top = 100;

//Add the table in paragraphs collection of the desired section

//sec1.Paragraphs.Add(tab1);

doc.Pages[1].Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "100 100 70 100 100 70 70 100 80";

//tab1 .PositioningType = PositioningType.ColumnRelative;

//Set default cell border using BorderInfo object

tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo( Aspose.Pdf.BorderSide.All, 1F);

//Set table border using another customized BorderInfo object

tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);

//ini baris judul

Aspose.Pdf.Row row1 = tab1.Rows.Add();

row1.BackgroundColor = Aspose.Pdf.Color.Beige; //("#F538FF");

// row1.DefaultCellTextState.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

// row1.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

row1.Cells.Add("Nomor Perjanjian");

row1.Cells.Add("Judul Perjanjian");

row1.Cells.Add("Jenis");

row1.Cells.Add("Tanggal Perjanjian");

row1.Cells.Add("Tanggal Penyampaian");

row1.Cells.Add("Pihak Ketiga");

row1.Cells.Add("Harga");

row1.Cells.Add("Jangka Waktu");

row1.Cells.Add("Keterangan");

string jenis;

string tanggalPenyampaianPerjanjian = " - ";

string tanggalPerjanjian = "";

string pihakKetiga = " - ";

string harga = " - ";

string jangkaWaktu = " - ";

string keterangan = "";

for (int i = 0; i < 100; i++)

{

Aspose.Pdf.Row rowTable = tab1.Rows.Add();

// rowTable.DefaultCellTextState.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

// rowTable.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

rowTable.Cells.Add("content 1");

rowTable.Cells.Add("content 2");

rowTable.Cells.Add("content 3");

rowTable.Cells.Add("content 4");

rowTable.Cells.Add("content 5");

rowTable.Cells.Add("content 6");

rowTable.Cells.Add("content 7");

rowTable.Cells.Add("content 8");

rowTable.Cells.Add("content 9");

}

doc.Save(“c:/pdftest/LargeTable_Test.pdf”);