Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Mon Sep 24, 2012 11:34 am

Hello,

I can't figure out how to insert some vertical text, to be on a side of a document. Could you please provide me a short example?
Thank you very much.

catalin
 
Posts: 48
Joined: Wed Mar 14, 2012 12:56 pm

Tue Sep 25, 2012 8:45 am

Dear catalin,

Thanks for your inquiry.
If inserting some vertical text into a document directly that can result in whole document into vertical, so we decide to put text into a table, and set the featrue "TextDirection.RightToLeftRotated". If you still have the problem, please tell us.
Code: Select all
            Document document = new Document();
            Table table = document.AddSection ().AddTable();
            table.ResetCells(1,1);
            TableCell cell = table.Rows[0].Cells[0];
            table.Rows[0].Height =150;
            cell.AddParagraph().AppendText("Hello,world: vertical style");           
            cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated;
            document.SaveToFile("sample.docx",FileFormat.Docx );


Best regards,
Amy
e-iceblue support
User avatar

amy.zhao
 
Posts: 2318
Joined: Wed Jun 27, 2012 8:50 am

Wed Sep 26, 2012 12:52 pm

Yes, it works, but i would like to insert some text as a sort of a sidebar, something like a copyright text, which will on the right side, in a vertical position, outside my main document content.

Can i do that with Spire.Doc?

Thank you

catalin
 
Posts: 48
Joined: Wed Mar 14, 2012 12:56 pm

Thu Sep 27, 2012 11:00 am

Dear catalin,

About your requirement, we provide you a demo. If you have any problem, please feel free to contact us.
Code: Select all
            Document document = new Document("Word.doc");
            Table table = document.Sections[0].AddTable();
            table.ResetCells(1, 1);
            TableCell cell = table.Rows[0].Cells[0];
            table.Rows[0].Height = 150;
            table.Rows[0].Cells[0].Width = 10;
            cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated;
            cell.AddParagraph().AppendText("Hello,world: vertical style");

            table.TableFormat.WrapTextAround = true;
            table.TableFormat.Positioning.VertRelationTo = VerticalRelation.Page;
            table.TableFormat.Positioning.HorizRelationTo = HorizontalRelation.Page;
            table.TableFormat.Positioning.HorizPosition = document.Sections[0].PageSetup.PageSize.Width - table.Width;
            table.TableFormat.Positioning.VertPosition = 200;

            document.SaveToFile("sample.docx", FileFormat.Docx);

Best regards,
Amy
e-iceblue support
User avatar

amy.zhao
 
Posts: 2318
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc