How to Rotate Text in PDF using C#

This how-to guide explains the process to rotate text in PDF using C#. It provides detailed information on environment configuration, to-do steps, and a runnable sample code to rotate text in Acrobat using C#. You will also learn to set different properties of the text fragment along with setting the rotation angle.

Steps to Rotate Text in PDF using C#

  1. Establish the environment to add Aspose.PDF for .NET to rotate text
  2. Create a new PDF using the Document class object and add a new page to it
  3. Create a TextFragment object and set parameters like position, font, and rotation angle
  4. Create a TextBuilder object using the newly added page above
  5. Append the text fragment to the text builder object
  6. Save the resultant PDF file on the disk having rotated text in it

These steps describe the operation to rotate text on PDF using C#. It highlights all the necessary classes, methods and properties used in the sample code like the Document class for creating the PDF file, the TextFragment class for creating the text and settings its properties and the TextBuilder class to finally add the rotated text in the PDF.

Code to Rotate Text in Adobe Acrobat using C#

This code demonstrates the process to rotate text in Adobe using C# where TextFragment class is used for creating a text element and setting its properties like position is set by providing XIndent and YIndent, the font is set by size and font name, and rotation is set by angle. The TextBuilder class is used to append text fragments as well as append paragraphs to the document if required.

This article has taught us to add and rotate text in a PDF. If you want to learn the process to add a watermark in a PDF, refer to the article on how to add watermark to PDF in C#.

 English