View previous topic :: View next topic |
Author |
Message |
cquadalti
Joined: 13 Feb 2008 Posts: 2
|
Posted: Wed Feb 13, 2008 7:57 am Post subject: MigraDoc center table in a page |
|
|
I can't center a table in a page. I insert two paragraph: one for logo, one for title and then a table with 2 columns, all centered in the page but the property table.Format.Alignment = ParagraphAlignment.Center not center the table. Where is the problem? here my code, thanks!
// Add a paragraph to the section
Paragraph logoParagraph = section.AddParagraph();
Paragraph logotextParagraph = section.AddParagraph();
// Add some text to the paragraph
logoParagraph.Format.Alignment = ParagraphAlignment.Center;
MigraDoc.DocumentObjectModel.Shapes.Image logo = logoParagraph.AddImage(Server.MapPath("/Account/logobmp.BMP"));
logo.Height = "60pt";
logo.LockAspectRatio = true;
logotextParagraph.Format.Alignment = ParagraphAlignment.Center;
logotextParagraph.AddFormattedText("Modulo Account", boldFont);
logotextParagraph.Format.SpaceBefore = "1cm";
logotextParagraph.Format.SpaceAfter = "1cm";
// Create the item table
MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
table.Format.Alignment = ParagraphAlignment.Center;
table.Borders.Width = 0.5;
table.Borders.Left.Width = 0.5;
table.Borders.Right.Width = 0.5;
MigraDoc.DocumentObjectModel.Tables.Column column;
// Before you can add a row, you must define the columns
column = table.AddColumn();
column.Width = "2cm";
column = table.AddColumn();
column.Width = "5cm"; |
|
Back to top |
|
|
cquadalti
Joined: 13 Feb 2008 Posts: 2
|
Posted: Mon Feb 18, 2008 3:10 pm Post subject: |
|
|
There is another method or tecnique for center a table?
table.Format.Alignment = ParagraphAlignment.Center doesn't work. |
|
Back to top |
|
|
chf
Joined: 14 Mar 2008 Posts: 2
|
Posted: Fri Mar 14, 2008 1:13 am Post subject: Table alignment |
|
|
Could you resolve this issue? I've same problem.
table.Format.Alignment = ParagraphAlignment.Center doesn't work because this property is for cells alignment. |
|
Back to top |
|
|
chf
Joined: 14 Mar 2008 Posts: 2
|
Posted: Fri Mar 14, 2008 2:38 am Post subject: |
|
|
I found a solution for this issue.
TextFrame addressFrame;
addressFrame = section.AddTextFrame();
addressFrame.LineFormat.Width = 0.5; //Only for visual purposes
addressFrame.Height = "15.0cm";//any number
addressFrame.Width = "10.0cm";//sum of col widths
addressFrame.Left = ShapePosition.Center;
addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;//irrelevant
addressFrame.Top = "10.0cm";//irrelevant
addressFrame.RelativeVertical = RelativeVertical.Page;//irrelevant
Table table = addressFrame.AddTable();
//Here other table parameters
Enjoy |
|
Back to top |
|
|
|