PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
MigraDoc center table in a page http://forum.pdfsharp.com/viewtopic.php?f=2&t=321 |
Page 1 of 1 |
Author: | cquadalti [ 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"; |
Author: | cquadalti [ 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. |
Author: | chf [ 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. |
Author: | chf [ 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 |
Author: | John_Mc [ Fri Aug 09, 2013 5:20 pm ] |
Post subject: | Re: MigraDoc center table in a page |
Thanks chf - exactly what I was looking for! |
Author: | gastan [ Mon Oct 01, 2018 7:54 pm ] |
Post subject: | Re: MigraDoc center table in a page |
Worked like this (to horizontaly center table with chart): Code: TextFrame addressFrame; addressFrame = document.LastSection.AddTextFrame(); addressFrame.Height = "6.0cm";//any number addressFrame.Width = "9.0cm";//sum of col widths addressFrame.Left = ShapePosition.Center; var table = addressFrame.AddTable(); would be happier if I did not have to specify dimensions, but so far so good |
Author: | TH-Soft [ Mon Oct 01, 2018 8:13 pm ] |
Post subject: | Re: MigraDoc center table in a page |
gastan wrote: Worked like this (to horizontally center table with chart) Putting the table into a TextFrame prevents the table from breaking across multiple pages.For a clean indentation that works across pagebreaks, use Code: table.Rows.LeftIndent Knowing the width of the page and the width of the table, it is simple to calculate the left indent needed to centre the table. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |