In one of my application we use PDF4NET
to print data onto an pdf-file. For this goal we use the method DrawText
.
Right now the question has arisen that for specific countries/labels (Arabic) the orientation must change from Left to Right
to Right to Left
Current method to print text:
page.Canvas.DrawText(strObj, mainXmlNode.PDFFont, Nothing, pdfnode.PDFBrush, pdfnode.X , pagePosY, pdfnode.Angle)
Method Definition of DrawText
Public Sub DrawText(ByVal text As String, ByVal font As O2S.Components.PDF4NET.Graphics.PDFFont,
ByVal pen As O2S.Components.PDF4NET.Graphics.PDFPen,
ByVal brush As O2S.Components.PDF4NET.Graphics.PDFBrush,
ByVal x As Single, ByVal y As Single,
ByVal orientation As Single)
Changing the orientation/Angle to +180
or -180
causes the text to drawn upsidedown
. So not quite the result i needed.
My idea was to use the StrInverse to inverse the order of my String
and the print it right to left
. yet this last step keeps bugging me. I can't seem to find the correct method/parameters to change the direction that String is printed.
So my question to you all, have any of you come across this same problem and how did you tackle it?
Thank you for your time
Update: Any other (non PDF4Net) solutions are welcome aswell.
Note: This has to be .NET 2.0 Compatible
I've found the solution:
the method DrawText
has another definition:
Public Sub DrawText(ByVal text As String,
ByVal font As O2S.Components.PDF4NET.Graphics.PDFFont,
ByVal pen As O2S.Components.PDF4NET.Graphics.PDFPen,
ByVal brush As O2S.Components.PDF4NET.Graphics.PDFBrush,
ByVal x As Single,
ByVal y As Single,
ByVal orientation As Single,
ByVal align As O2S.Components.PDF4NET.Graphics.Shapes.TextAlign)
Don't be decieved by the name Align
. This isn't actually an Align as you would do inside a textbox
. Although it has same the possiblities:
BottomCenter
BottomLeft
BottomRight
MiddleCenter
...
When using the Drawtext
-method with an align, it will start printing in its direction.
example
Public Sub DrawText("abc",....,12,14,0,TextAlign.BottomRight)
This will print abc
starting at (x= 12 & y=14)
but with all the letters printed to the left of that point starting with c
It would look as follows with the point presenting (by approximation) x=12 & y=14
:
abc.