PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Automatic expanding TextFrame https://forum.pdfsharp.net/viewtopic.php?f=2&t=682 |
Page 1 of 1 |
Author: | Orestone [ Thu Mar 19, 2009 7:24 am ] |
Post subject: | Automatic expanding TextFrame |
Is it possible to make a TextFrame increase its Height to contain its content? for example the following code snippet creates a TextFrame with a border but the borders only 'contain' lines 1 to 6. Lines 7 to 9 fall outside the borders. Code: private void AddLeftBox(Section section) { var frame = section.AddTextFrame(); frame.Width = new Unit(80.0, UnitType.Millimeter); frame.LineFormat.Width = Unit.FromPoint(0.5); for (int i = 1; i < 10; i++) frame.AddParagraph("Line " + i); } Failing an automatic way of doing this is there a way to measure the contents of the TextFrame after they have been added and then retrospectively set the TextFrame.Height property[/code] |
Author: | Thomas Hoevel [ Thu Mar 19, 2009 7:52 am ] |
Post subject: | |
Workaround: add a table to the textframe and set the border of the table. |
Author: | Orestone [ Thu Mar 19, 2009 7:46 pm ] |
Post subject: | |
Thanks Thomas. I was hoping not to clutter the structure of the document like that but I shall take your suggestion on board. Is this unimplemented functionality/feature in MigraDoc or is there a reason why the TextFrame behaves that way? Cheers Simon |
Author: | Orestone [ Fri Mar 20, 2009 1:40 am ] |
Post subject: | |
Just to add closure for others' benefit - this is an acceptable workaround for my situation Code: private void AddLeftBox(Section section) { var frame = section.AddTextFrame(); Table table = frame.AddTable(); table.Borders.Width = 0.5; table.LeftPadding = 0; var column = table.AddColumn(); column.Width = Unit.FromMillimeter(80); Row row = table.AddRow(); for (int i = 1; i < 10; i++) row[0].AddParagraph("Line " + i); } The line Code: table.LeftPadding = 0; ensures that the table is aligned with other paragraph borders in my document. You may not need this in other applications (as appropriate).
Thanks again |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |