We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to rotate a single line of text in my pdf?

Thread ID:

Created:

Updated:

Platform:

Replies:

108635 May 3,2013 11:05 AM Aug 28,2014 03:27 AM ASP.NET Web Forms (Classic) 4
loading
Tags: PDF
Gert Van Meerbergen
Asked On May 3, 2013 11:05 AM

I'm currently trying to rotate a single line of text in my pdf. This is proving harder than expected.
Using .Graphics.TransformRotate(45) on the PdfPage isn't really an option since I'm using it in a for loop.

Here's an example of what I'm trying to do:

For Each value As values
Dim originalState As PdfGraphicsState = currentPage.Graphics.Save()
currentPage.Graphics.RotateTransform(45)
currentPage.Graphics.DrawString(...)
currentPage.Graphics.Restore(originalState)
Next

Now this requires some complex logic for the x and y values in the DrawString, so I'm hoping I can somehow only rotate the string I'm drawing there. If needed I can always store it in a PdfTextElement. But even on the element I haven't found a way to fix this.

KarthikeyanC [Syncfusion]
Replied On May 8, 2013 01:37 AM

Hi Gert,

Thank you for your interest in Syncfusion Products.

 

While using RotateTransform, it will transform the whole coordinate system to the angle mentioned.

So the default coordinates will change accordingly.

Using some mathematical calculations I have tried calculating the new coordinates.

   Dim xNew As Double = x * Math.Cos(angle) - y * Math.Sin(angle)

   Dim yNew As Double = x * Math.Sin(angle) + y * Math.Cos(angle)

 

I also attached a sample for your reference.

TextRotationVB.zip

Please let us know if you have any concern.

 

 

Thanks,

Karthikeyan.C

 


Gert Van Meerbergen
Replied On May 8, 2013 04:22 AM

Hi Karthikeyan

Unfortunately your solution does not work for me. I have added a zip with 2 images: what we want to achieve (wanted.png) and what we currently have (current.png).

As you can see on the image, we want to have a rotated text (45 degrees) with a different x-axis value and aligned on the y-axis.


result_cee416c1.zip

KarthikeyanC [Syncfusion]
Replied On May 13, 2013 12:22 AM

Hi Gert,

Thank you for your update.

 

I have modified the sample according to your new image attached.

Please refer the sample, you may adjust the values to get the text in the proper destination in your document.

TextRotationVB.zip

 

Please let us know if you have any concern.

 

Thanks,

Karthikeyan.C

 


Luca Cavicchioli
Replied On August 28, 2014 03:27 AM

I'm also interested in the answer and I'd like to take a look at the saples proposed but when I'm trying to download them I always receive the error message:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
[...]

Please fix the problem I'm also trying to print rotated string but what I'm getting is an empty PDF.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;