Rotate Text inside PDF Documents in C#

If you are generating PDF files programmatically, you may need to rotate PDF text at a specific angle. Changing the orientation and position of a text in a PDF could be tricky. However, the solution provided in this article has made rotating text in PDF using C# quite easy. So let’s dig down and check how to rotate text in a PDF in C#.

C# Library to Rotate Text in PDF

To rotate text in PDF, we will use Aspose.PDF for .NET. It is a C# class library that provides basic as well as advanced PDF manipulation features for .NET applications. Using the library, you can generate PDF documents with simple or complex layouts seamlessly.

You can either download the library’s DLL or install it using NuGet.

PM> Install-Package Aspose.PDF

How to Rotate Text in PDF in C#

There are multiple ways to rotate text in a PDF file using C#. You can either rotate a text fragment or the complete paragraph. Let’s see how each of these text rotations works.

C# Rotate Text in PDF using TextFragment

The following are the steps to rotate a text fragment in a PDF using C#.

The following code sample shows how to rotate text in a PDF in C#.

Output

PDF Text Rotation using TextFragment in C#

Rotate PDF Text using TextParagraph in C#

You can also apply rotation to the text while creating a new paragraph. This can be achieved using TextParagraph class. The following are the steps to apply text rotation in PDF using TextParagraph class.

The following code sample shows how to rotate text in a paragraph of PDF in C#.

Output

PDF Text Rotation using TextParagraph in C#

Free C# Library to Rotate Text in PDF

You can get a free temporary license and rotate text in PDF files without any limitations.

Explore C# PDF Library

You can explore other features of the C# PDF library using the documentation. In case you would have any questions or queries, you can contact us via our forum.

Conclusion

PDF automation is widely adopted to create and manipulate PDF documents from within the web or desktop applications. In this article, you have learned how to rotate text in PDF using C#. We have explicitly covered how to rotate text using TextFragment and TextParagraph classes. You can easily use the provided code samples in your applications after integrating our C# PDF library.

See Also