- Home
- Forum
- ASP.NET Web Forms (Classic)
- How to rotate a single line of text in my pdf?
How to rotate a single line of text in my pdf?
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.
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.
Please let us know if you have any concern.
Thanks,
Karthikeyan.C
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
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.
Please let us know if you have any concern.
Thanks,
Karthikeyan.C
- 4 Replies
- 3 Participants
-
GV Gert Van Meerbergen
- May 3, 2013 03:05 PM UTC
- Aug 28, 2014 07:27 AM UTC