View previous topic :: View next topic |
Author |
Message |
Orestone
Joined: 24 Oct 2008 Posts: 7 Location: Brisbane, Australia
|
Posted: 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] |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Thu Mar 19, 2009 7:52 am Post subject: |
|
|
Workaround: add a table to the textframe and set the border of the table. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
Orestone
Joined: 24 Oct 2008 Posts: 7 Location: Brisbane, Australia
|
Posted: 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 |
|
Back to top |
|
|
Orestone
Joined: 24 Oct 2008 Posts: 7 Location: Brisbane, Australia
|
Posted: 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 |
|
Back to top |
|
|
|