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.
Mon Jul 30, 2018 6:11 pm
I'm working with a landscape pdf template, and I'm trying to add a table to it. The table is being printed at a 90-degree angle. How can I rotate it? It seems to think the page is in portrait mode.
-
jumper4000
-
- Posts: 12
- Joined: Thu Mar 01, 2018 11:46 pm
Tue Jul 31, 2018 2:48 am
Hello,
Thank you for your post.
To help us look into the issue, could you please share your code snippet as well as the input and output file?
Sincerely,
Jane
E-iceblue support team
-
Jane.Bai
-
- Posts: 1156
- Joined: Tue Nov 29, 2016 1:47 am
Fri Nov 25, 2022 2:35 pm
Any update on this thread?
I want to draw pdf table and it should be landscape.
PdfDocument pdfDoc = new PdfDocument(path);
PdfPageBase tablePage= pdfDoc .Pages.Add();
PdfTable table = new PdfTable();
table.AllowCrossPages = true;
table.DataSourceType = PdfTableDataSourceType.TableDirect;
table.DataSource = GetTableData();
table.Style.ShowHeader = true;
table.Style.HeaderStyle.BorderPen = new PdfPen(brush);
table.Style.HeaderStyle.BackgroundBrush = new PdfSolidBrush(Color.LightGray);
PdfLayoutResult pdfLayoutResult = table.Draw(tablePage, new PointF(0,0));
-
kannangandhi
-
- Posts: 1
- Joined: Fri Nov 25, 2022 2:25 pm
Mon Nov 28, 2022 10:12 am
Hello,
Thanks for your inquiry.
Do you want to add a landscape page to pdf document then draw table? If so, please refer to the following code:
- Code: Select all
PdfDocument doc = new PdfDocument();
//Set the margin
PdfMargins margin = new PdfMargins();
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
//Create one page and set the orientation to landscape
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin, PdfPageRotateAngle.RotateAngle0, PdfPageOrientation.Landscape);
float y = 320;
//Title
PdfBrush brush1 = PdfBrushes.Black;
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold));
PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
page.Canvas.DrawString("Country List", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
y = y + font1.MeasureString("Country List", format1).Height;
y = y + 5;
String[] data
= {
"Name;Capital;Continent;Area;Population",
"Argentina;Buenos Aires;South America;2777815;32300003",
"Bolivia;La Paz;South America;1098575;7300000"
};
String[][] dataSource
= new String[data.Length][];
for (int i = 0; i < data.Length; i++)
{
dataSource[i] = data[i].Split(';');
}
PdfTable table = new PdfTable();
table.Style.CellPadding = 2;
table.Style.HeaderSource = PdfHeaderSource.Rows;
table.Style.HeaderRowCount = 1;
table.Style.ShowHeader = true;
table.DataSource = dataSource;
//Draw table
PdfLayoutResult result = table.Draw(page, new PointF(60, y));
doc.SaveToFile(@"../../output/result1.pdf", FileFormat.PDF);
Sincerely
Abel
E-iceblue support team
-
Abel.He
-
- Posts: 959
- Joined: Tue Mar 08, 2022 2:02 am
Mon Nov 28, 2022 10:14 am
Hi,
I have posted a question regarding making text fixed at the right and left edges on the same line.
Can you please look into it.
-
suryaks2002
-
- Posts: 17
- Joined: Wed Nov 09, 2022 7:57 am
Tue Nov 29, 2022 10:13 am
suryaks2002 wrote:Hi,
I have posted a question regarding making text fixed at the right and left edges on the same line.
Can you please look into it.
Hello,
I have replied to you in your post.
Sincerely
Abel
E-iceblue support team
-
Abel.He
-
- Posts: 959
- Joined: Tue Mar 08, 2022 2:02 am