PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Vertical text in MigraDoc table
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1990
Page 1 of 1

Author:  Klitgaard [ Wed Apr 25, 2012 11:47 am ]
Post subject:  Vertical text in MigraDoc table

Hi there,
I am generating a table with Migradoc and want to have a number of rows in it - and a column in the left hand side with vertical text.
What I basically do is
1. create a two-column table
2. add a number of rows
3. MergeDown all Cells[0]
4. Write a Paragraph in a TextFrame with Orientation=TextOrientation.Upward.
There is enough vertical space for all text in cell[0] to fit in the table on a single line, but nevertheless, the text is wrapped (see attached image). How do I avoid that ?
The simple source code example is given below.
Thanks a lot for any help :-)

public void DummyReport(string reportFilename)
{
Document document = new Document();
Section section = document.AddSection();
Table dataTbl = section.AddTable();
dataTbl.Borders.Color = TableBorder;

// Two columns - the first vertical, the next horisontal
Column column = dataTbl.AddColumn("0.5cm"); // Left vertical text...
column = dataTbl.AddColumn("4.25cm");

// Create a number of rows
for (int i = 0; i <= 20; i++)
dataTbl.AddRow();


//Merge the cells in the first column and write vertical text in it
Cell leftSideCell = dataTbl.Rows[0].Cells[0];
leftSideCell.MergeDown = dataTbl.Rows.Count - 1;
leftSideCell.VerticalAlignment = VerticalAlignment.Center;
TextFrame leftTF = leftSideCell.AddTextFrame();
leftTF.Orientation = TextOrientation.Upward;
leftTF.WrapFormat.Style = WrapStyle.None;

Paragraph leftPar = leftTF.AddParagraph("How do I avoid this text getting wrapped ?");

// Now generate a pdf
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

// Set the MigraDoc document
pdfRenderer.Document = document;

// Create the PDF document
pdfRenderer.RenderDocument();

// Save the PDF document...
pdfRenderer.Save(reportFilename);

}


Attachments:
WrappedVerticalText.jpg
WrappedVerticalText.jpg [ 42.89 KiB | Viewed 17518 times ]

Author:  Thomas Hoevel [ Wed Apr 25, 2012 3:07 pm ]
Post subject:  Re: Vertical text in MigraDoc table

Hi!

The textframe has a width and a height (you should be able to set the border of the textframe to make it visible).
Setting the width should be easy (0.5 cm), setting the height could be tricky. If your rows have a fixed height or a minimum height, you can set the height of the textframe accordingly and text should not wrap.

A similar problem, solved by mixing PDFsharp and MigraDoc:
viewtopic.php?f=2&t=1619&p=4541&hilit=vertical#p4541

Author:  Klitgaard [ Tue May 01, 2012 12:50 pm ]
Post subject:  Re: Vertical text in MigraDoc table

Thanks a lot - works perfectly :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/