Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Fri Feb 12, 2016 6:32 pm
Hi,
I've an existing pdf and in the first page middle section i want to insert a table. Can we do it with Spire?
From all the articles I see that the table has to be in an independent/new page. Can we add the table to an existing page?
Appreciate your response.
Thanks
-

santuvssantu
-
- Posts: 98
- Joined: Fri Feb 12, 2016 5:21 pm
Sun Feb 14, 2016 2:16 am
Hi,
Thanks for your posting.
Sorry that the feature can not be supported now.
Welcome to feel free to write to us again if you have further problems.
Best Regards,
Amy
E-iceblue support team
-


amy.zhao
-
- Posts: 3011
- Joined: Wed Jun 27, 2012 8:50 am
Mon Feb 15, 2016 9:37 pm
Hi Amy,
Thanks for your response. I've another question.
If not in existing pdf, in a new pdf can we add multiple tables in one page? What I want to do is, add 3 tables in a new page. Is that possible?
Thanks
-

santuvssantu
-
- Posts: 98
- Joined: Fri Feb 12, 2016 5:21 pm
Tue Feb 16, 2016 2:23 am
Hi,
Yes,it is supported. Please refer to the following sample code.
- Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
PdfBrush brush = PdfBrushes.Black;
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold));
String[] data1
= {
"Name;Capital;Continent;Area;Population",
"Argentina;Buenos Aires;South America;2777815;32300003",
"Bolivia;La Paz;South America;1098575;7300000"
};
String[][] dataSource
= new String[data1.Length][];
for (int i = 0; i < data1.Length; i++)
{
dataSource[i] = data1[i].Split(';');
}
//Add the first table
PdfTable table1 = new PdfTable();
table1.Style.CellPadding = 2;
table1.Style.HeaderSource = PdfHeaderSource.Rows;
table1.Style.HeaderRowCount = 1;
table1.Style.ShowHeader = true;
table1.DataSource = dataSource;
float y = 10;
PdfLayoutResult result = table1.Draw(page, new PointF(0, y));
y = y + result.Bounds.Height + 5;
String[] data2
= {
"Name;Capital;Continent;Area;Population",
"El Salvador;San Salvador;North America;20865;5300000",
"Guyana;Georgetown;South America;214969;800000",
"Jamaica;Kingston;North America;11424;2500000",
"Mexico;Mexico City;North America;1967180;88600000"
};
dataSource= new String[data2.Length][];
for (int i = 0; i < data2.Length; i++)
{
dataSource[i] = data2[i].Split(';');
}
//Add the second table
PdfTable table2 = new PdfTable();
table2.Style.CellPadding = 2;
table2.Style.HeaderSource = PdfHeaderSource.Rows;
table2.Style.HeaderRowCount = 1;
table2.Style.ShowHeader = true;
table2.DataSource = dataSource;
result = table2.Draw(page, new PointF(0, y));
y = y + result.Bounds.Height + 5;
String[] data3
= {
"Name;Capital;Continent;Area;Population",
"Nicaragua;Managua;North America;139000;3900000",
"Paraguay;Asuncion;South America;406576;4660000",
"Peru;Lima;South America;1285215;21600000"
};
dataSource = new String[data3.Length][];
for (int i = 0; i < data3.Length; i++)
{
dataSource[i] = data3[i].Split(';');
}
//Add the third table
PdfTable table3= new PdfTable();
table3.Style.CellPadding = 2;
table3.Style.HeaderSource = PdfHeaderSource.Rows;
table3.Style.HeaderRowCount = 1;
table3.Style.ShowHeader = true;
table3.DataSource = dataSource;
result = table3.Draw(page, new PointF(0, y));
string output = "result.pdf";
doc.SaveToFile(output);
System.Diagnostics.Process.Start(output);
Best Regards,
Amy
E-iceblue support team
-


amy.zhao
-
- Posts: 3011
- Joined: Wed Jun 27, 2012 8:50 am
Wed Feb 17, 2016 8:32 am
Hi,
Did my sample code help you?
Thanks for your feedback.
Best Regards,
Amy
E-iceblue support team
-


amy.zhao
-
- Posts: 3011
- Joined: Wed Jun 27, 2012 8:50 am
Wed Feb 17, 2016 4:52 pm
Yes, Thank you very much Amy.
Thanks
-

santuvssantu
-
- Posts: 98
- Joined: Fri Feb 12, 2016 5:21 pm
Thu Feb 18, 2016 1:50 am
Hi,
Thanks for your feedback.
Welcome to feel free to write to us if you have further problems.
Best Regards,
Amy
E-iceblue support team
-


amy.zhao
-
- Posts: 3011
- Joined: Wed Jun 27, 2012 8:50 am