Following on from my difficulties with Concatenation of documents that included Formfields, I have been looking at creating each document without form fields and using drawstring for each item.
Could anyone assist with suggestions about text rotation where there are multiple items of text.
I have experimented using the Hello World example but placing 2 text strings on the document and rotating the string when drawing using RotateAtTransform. I can prevent the rotation for each string by commenting out the RotateAtTransform command. This way I can sample all 4 possible cases for the two strings.
Unfortunately I find that I am not getting each string rotated with the following results:
Instruction // Result Test Text A / Text B / Text A / Text B 1 Horizontal (No rot) / Horizontal / A Horizontal / B Horizontal 2 Rotate / Horizontal / A Rotated / B NOT shown 3 Horizontal (No Rot) / Rotate / A Horizontal / B Rotated 4 Rotate / Rotate / A Rotated / B NOT shown ----- Same RESULT as Test 2 From the tests, I can conclude that the string is not drawn IF I have already done a RotateAtTransform for a previous string.
Could anyone advise what I am doing wrong or what I need to add after each transformation so that any further strings get then get drawn and rotated as needed?
I would be pleased for any comments as having looked at many examples, I cannot see what I need to do differently.
Code:- Public Sub testpdf() Dim document As PdfDocument = New PdfDocument() document.Info.Title = "Created with PDF sharp"
'CreateObject empty page Dim page As PdfPage = document.AddPage()
'create an xgraphics object for drawing Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
'draw crossing lines Dim pen As XPen = New XPen(XColor.FromArgb(255, 0, 0)) gfx.DrawLine(pen, New XPoint(0, 0), New XPoint(page.Width.Point, page.Height.Point)) gfx.DrawLine(pen, New XPoint(page.Width.Point, 0), New XPoint(0, page.Height.Point))
'draw ellipse gfx.DrawEllipse(pen, 3 * page.Width.Point / 10, 3 * page.Height.Point / 10, 2 * page.Width.Point / 5, 2 * page.Height.Point / 5)
'create font Dim font As XFont = New XFont("Arial", 72, XFontStyle.Regular) Dim OPfilename As String = "HelloworldTest1.pdf"
'draw Title gfx.DrawString("1", font, XBrushes.Black, New XRect(page.Width.Point / 2, page.Height.Point / 2, 50, 72), XStringFormats.CenterLeft)
font = New XFont("Arial", 12, XFontStyle.Regular)
'TEST 'draw text A '.RotateAtTransform(90, New XPoint(22, 300)) gfx.DrawString("AAAAAAAA", font, XBrushes.Black, New XRect(22, 300, 50, 20), XStringFormats.CenterLeft)
'draw text B ' gfx.RotateAtTransform(90, New XPoint(425, 560)) gfx.DrawString("BBBBBBBB", font, XBrushes.Black, New XRect(425, 560, 50, 20), XStringFormats.CenterRight)
' SAVE the document document.Save(strNamePath & "\PDTIX\Created" & OPfilename)
' start a viewer Process.Start(strNamePath & "\PDTIX\Created" & OPfilename)
End Sub
Attachments: |
File comment: Test3 result
HWTest3.jpg [ 240.13 KiB | Viewed 4485 times ]
|
File comment: Test2 result
HWTest2.jpg [ 238.58 KiB | Viewed 4485 times ]
|
File comment: Test1 result
HWTest1.jpg [ 238.94 KiB | Viewed 4485 times ]
|
|