Aspose.Pdf

Set Text Direction in Table or Floating Box

Aspose.Pdf offers developers to set the direction of text in Table Cells and Floating Box by adding a property named VerticalTextRotationType . Aspose.Pdf provides an enumeration VerticalTextRotationType that comes with pre-defined types of directions as follows:

 

Member Name

Description

None

No rotation type is used. This means rotation angle is 0.

ClockWise

90

AntiClockWise

-90

 

In the examples below, we are going to show how to create vertical text in

 

 

Code Snippet

 

Example: Table Cell

 

[C#]

 

        Pdf pdf = new Pdf();

        //Add Section

        Aspose.Pdf.Section sec1 = pdf.Sections.Add();

        //Add Table

        Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();

        //Add Paragraph

        sec1.Paragraphs.Add(table1);

        //Add one row in the table to show Anticlockwise Text

        Row row2 = table1.Rows.Add();

        //Define one cell and add Text in it

        Cell cell1Row2 = row2.Cells.Add("cells Showing     Data AnticlockWise");

        //Set Cell Border

        cell1Row2.Border = new BorderInfo((int)BorderSide.All, 0.5F);

        //Set the VerticalText Property to show text in AnticlockWise Direction

        cell1Row2.VerticalTextRotationAngle = VerticalTextRotationType.AntiClockWise;

 

        //Add another cell with set VerticalTextRotationAngle Property to ClockWise

        Cell cell2Row2 = row2.Cells.Add("cells Property Showing       clockWise Direction");

        cell2Row2.Border = new BorderInfo((int)BorderSide.All, 0.5F, new Aspose.Pdf.Color("Red"));

        cell2Row2.VerticalTextRotationAngle = VerticalTextRotationType.ClockWise;

 

        pdf.Save("D:/SupportVerticalTextInCell.pdf");

 

[VB.NET]

 

        Dim pdf As New Pdf()

        'Add Section

        Dim sec1 As Aspose.Pdf.Section = pdf.Sections.Add()

        'Add Table

        Dim table1 As New Aspose.Pdf.Table()

        'Add Paragraph

        sec1.Paragraphs.Add(table1)

        'Add one row in the table to show Anticlockwise Text

        Dim row2 As Row = table1.Rows.Add()

        'Define one cell and add Text in it

        Dim cell1Row2 As Cell = row2.Cells.Add("cells Showing     Data AnticlockWise")

        'Set Cell Border

        cell1Row2.Border = New BorderInfo(CInt(BorderSide.All), 0.5F)

        'Set the VerticalText Property to show text in AnticlockWise Direction

        cell1Row2.VerticalTextRotationAngle = VerticalTextRotationType.AntiClockWise

 

        'Add another cell with set VerticalTextRotationAngle Property to ClockWise

        Dim cell2Row2 As Cell = row2.Cells.Add("cells Property Showing       clockWise Direction")

        cell2Row2.Border = New BorderInfo(CInt(BorderSide.All), 0.5F, New Aspose.Pdf.Color("Red"))

        cell2Row2.VerticalTextRotationAngle = VerticalTextRotationType.ClockWise

        pdf.Save("D:/SupportVerticalTextInCell.pdf")

 

Example: Floating Box

 

[C#]

 

        Pdf pdf = new Pdf();

        //Add Section

        Aspose.Pdf.Section sec1 = pdf.Sections.Add();

        //Add Table

        Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();

        //Define and instantiate a Floating box

        FloatingBox box1 = new FloatingBox(108, 156);

        //Add paragraph

        sec1.Paragraphs.Add(box1);

        //Set the Positioning and Alignment of Floating Box

        box1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Margin;

        box1.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Left;

        box1.BoxVerticalPositioning = BoxVerticalPositioningType.Margin;

        box1.BoxVerticalAlignment = BoxVerticalAlignmentType.Center;

        //Adding Text to a Paragraph

        box1.Paragraphs.Add(new Text("floating box Text Direction"));

        box1.Paragraphs.Add(new Text("This is Test"));

        box1.Paragraphs.Add(new Text(" "));

        box1.Paragraphs.Add(new Text("AnticlockWise"));

        box1.Paragraphs.Add(new Text(" "));

        //Set the Property to AnticlockWise

        box1.VerticalTextRotationAngle = VerticalTextRotationType.AntiClockWise;

        //Save the Pdf

        pdf.Save("D:/SupportVerticalTextInCell.pdf");

 

[VB.NET]

 

        Dim pdf As New Pdf()

        'Add Section

        Dim sec1 As Aspose.Pdf.Section = pdf.Sections.Add()

        'Add Table

        Dim table1 As New Aspose.Pdf.Table()

        'Define and instantiate a Floating box

        Dim box1 As New FloatingBox(108, 156)

        'Add paragraph

        sec1.Paragraphs.Add(box1)

        'Set the Positioning and Alignment of Floating Box

        box1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Margin

        box1.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Left

        box1.BoxVerticalPositioning = BoxVerticalPositioningType.Margin

        box1.BoxVerticalAlignment = BoxVerticalAlignmentType.Center

        'Adding Text to a Paragraph

        box1.Paragraphs.Add(New [Text]("floating box Text Direction"))

        box1.Paragraphs.Add(New [Text]("This is Test"))

        box1.Paragraphs.Add(New [Text](" "))

        box1.Paragraphs.Add(New [Text]("AnticlockWise"))

        box1.Paragraphs.Add(New [Text](" "))

        'Set the Property to AnticlockWise

        box1.VerticalTextRotationAngle = VerticalTextRotationType.AntiClockWise

        'Save the Pdf

        pdf.Save("D:/SupportVerticalTextInCell.pdf")

 

To get furthur details about VerticalTextRotationType please visit our online API documents.