PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 4:22 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Vertical Text
PostPosted: Fri Dec 21, 2007 9:03 pm 
Offline

Joined: Mon Dec 17, 2007 5:56 pm
Posts: 4
Location: Chile
I need posisioning vertical text exactly in a XPoint.

I try using a rectangle, from "top + height" to "top".

Still can't do it...

Code:
                        XGraphicsState gs = gfx.Save();                       
                        XGraphicsPath path = new XGraphicsPath();
                        gfx.TranslateTransform(45.0 , 10.0 + rect.Height / 3.0);
                        gfx.RotateTransform(-90);
                        gfx.TranslateTransform(-45.0 , -10.0 - rect.Height / 3.0);
                        rect.Width = rect.Height;
                        rect.Height = 20;
                        XTextFormatter tf = new XTextFormatter(gfx);
                        tf.Alignment = XParagraphAlignment.Center;
                        gfx.DrawPath(new XPen(pen.Color, 0.5), brush, path);
                        XRect rectVerticalText = new XRect(-rect.Top,rect.Left, rect.Width, rect.Height);
                        gfx.DrawRectangle(brushBlack,rectVerticalText);
tf.DrawString(ndName, font, brushFont, rectVerticalText, XStringFormat.TopLeft);
                             
                        gfx.Restore(gs);


Regards, José.[/code]

_________________
Salu2, JPavez


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 21, 2008 9:24 am 
Offline

Joined: Thu Sep 20, 2007 1:06 pm
Posts: 15
not sure what you're trying to do but this is the code I use to write vertical text to a specific rectangle (point, size);

XRect spineTitleBox = new XRect(rectangleY, document.width - rectangleX, TitleSize.Width, TitleSize.Height);

// Since you "turn the paper" you're writing to, the Y pos when you hold the paper upright becomes the X pos, and the new Y pos, is the total width of the document - the original X pos.

// set a new xy=0 pos
xgf.TranslateTransform(page.Width/2, page.Height/2);
// turn the paper from the ny xy=0
xgf.RotateTransform(90);
// reset the xy=0 to the upper left corner.
xgf.TranslateTransform(-page.Height/2, -page.Width/2);

// write your stuff
if(!string.IsNullOrEmpty(book.Title))
{
XBrush brush;
brush = Brushes.Black;

xgf.DrawString(book.Title, spineTitleFont, brush, spineTitleBox, XStringFormat.Center);
}

// set a new yx=0 pos
xgf.TranslateTransform(page.Height/2, page.Width/2);
// turn the paper back
xgf.RotateTransform(-90);
// reset the xy=0 to the upper left corner
xgf.TranslateTransform(-page.Width/2, -page.Height/2);


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 338 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