PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 16, 2024 5:12 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Apr 25, 2012 11:47 am 
Offline

Joined: Tue Apr 24, 2012 2:28 pm
Posts: 7
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 17098 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 25, 2012 3:07 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 01, 2012 12:50 pm 
Offline

Joined: Tue Apr 24, 2012 2:28 pm
Posts: 7
Thanks a lot - works perfectly :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 164 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group