Is there a way to change the orientation of the text. I.E from left to right to top down, or rotate text 90 degrees?
Additionally I downloaded the hotfix for the page numbering problem. “Page $p of $P” and It will still show “Page 1 of $P” please help me with that, thanks.
Dear aliberman,
Thanks for your consideration.
Top-down alignment of text or text rotation is not supported currently.
Would you please send me an example which can reproduce the page numbering problem?
We are excited to share with you that Aspose.PDF for .NET now offers the capability to rotate text during PDF generation scenarios. Please consider checking following code snippet and use it with the latest version of the API:
Rotate text Using TextFragment + TextBuilder
//open document
Document pdfDocument = new Document();
//get particular page
Page pdfPage = (Page)pdfDocument.Pages.Add();
//create text fragment
TextFragment textFragment1 = new TextFragment("main text");
textFragment1.Position = new Position(100, 600);
//set text properties
textFragment1.TextState.FontSize = 12;
textFragment1.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//create rotated text fragment
TextFragment textFragment2 = new TextFragment("rotated text");
textFragment2.Position = new Position(200, 600);
//set text properties
textFragment2.TextState.FontSize = 12;
textFragment2.TextState.Font = FontRepository.FindFont("TimesNewRoman");
textFragment2.TextState.Rotation = 45;
//create rotated text fragment
TextFragment textFragment3 = new TextFragment("rotated text");
textFragment3.Position = new Position(300, 600);
//set text properties
textFragment3.TextState.FontSize = 12;
textFragment3.TextState.Font = FontRepository.FindFont("TimesNewRoman");
textFragment3.TextState.Rotation = 90;
// create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);
// append the text fragment to the PDF page
textBuilder.AppendText(textFragment1);
textBuilder.AppendText(textFragment2);
textBuilder.AppendText(textFragment3);
//save document
pdfDocument.Save("TextFragmentTests_Rotated1.pdf");
Rotate text using TextParagraph + TextBuilder (rotated fragments)
//open document
Document pdfDocument = new Document();
//get particular page
Page pdfPage = (Page)pdfDocument.Pages.Add();
TextParagraph paragraph = new TextParagraph();
paragraph.Position = new Position(200, 600);
//create text fragment
TextFragment textFragment1 = new TextFragment("rotated text");
//set text properties
textFragment1.TextState.FontSize = 12;
textFragment1.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//set rotation
textFragment1.TextState.Rotation = 45;
//create text fragment
TextFragment textFragment2 = new TextFragment("main text");
//set text properties
textFragment2.TextState.FontSize = 12;
textFragment2.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//create text fragment
TextFragment textFragment3 = new TextFragment("another rotated text");
//set text properties
textFragment3.TextState.FontSize = 12;
textFragment3.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//set rotation
textFragment3.TextState.Rotation = -45;
// append the text fragments to the paragraph
paragraph.AppendLine(textFragment1);
paragraph.AppendLine(textFragment2);
paragraph.AppendLine(textFragment3);
// create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);
// append the text paragraph to the PDF page
textBuilder.AppendParagraph(paragraph);
//save document
pdfDocument.Save("TextFragmentTests_Rotated2.pdf");
Rotate text using TextFragment + Page.Paragraphs
1. Document pdfDocument = new Document();
//get particular page
Page pdfPage = (Page)pdfDocument.Pages.Add();
//create text fragment
TextFragment textFragment1 = new TextFragment("main text");
//set text properties
textFragment1.TextState.FontSize = 12;
textFragment1.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//create text fragment
TextFragment textFragment2 = new TextFragment("rotated text");
//set text properties
textFragment2.TextState.FontSize = 12;
textFragment2.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//set rotation
textFragment2.TextState.Rotation = 315;
//create text fragment
TextFragment textFragment3 = new TextFragment("rotated text");
//set text properties
textFragment3.TextState.FontSize = 12;
textFragment3.TextState.Font = FontRepository.FindFont("TimesNewRoman");
//set rotation
textFragment3.TextState.Rotation = 270;
pdfPage.Paragraphs.Add(textFragment1);
pdfPage.Paragraphs.Add(textFragment2);
pdfPage.Paragraphs.Add(textFragment3);
//save document
pdfDocument.Save("TextFragmentTests_Rotated3.pdf");