Hello. I am trying to make yellow stripe and a blue stripe all the way down my page. On TOP of that I need to make varying rows of text (I cannot use tables because I need precise positioning). Every other line of text should be rotated. I used the sample code below to show two problem. Problem one is that rotating the text causes alignment and sizing problems (denoted in the code). The second is that the background color of the text ends up BLACK instead of showing whatever was underneath. Are these fixable problems? Any help is appreciated!!!
mat185974958.pdf (30.3 KB)
Private Sub pdftry()
Dim rnd As New Random
Dim d As New Aspose.Pdf.Document() 'create new document
Dim p As Aspose.Pdf.Page
p = d.Pages.Add() 'add page 1
p.SetPageSize(3 * 72, 3 * 72) 'set page to 3x3 "
Dim g1 As Aspose.Pdf.Drawing.Graph
Dim r As Aspose.Pdf.Drawing.Rectangle
Dim t As Aspose.Pdf.Text.TextFragment
p.PageInfo.Margin = New Aspose.Pdf.MarginInfo(0, 0, 0, 0) ' margins to 0
g1 = New Aspose.Pdf.Drawing.Graph(72, 2 * 72) 'build a 1"x2" graph to work in
g1.IsChangePosition = False
g1.GraphInfo.RotationAngle = 0
g1.Left = 0
g1.Top = 0
g1.Border = New BorderInfo(BorderSide.All) 'put a border so we can see what's going on
'''' here we draw a blue stripe and a yellow stripe. We want the text to eventually be on top of these stripes
'draw yellow
r = New Aspose.Pdf.Drawing.Rectangle(0, 0, 36, 3 * 72) 'build a yellow rectangle that takes up the first 1/2" of our graphics area
r.GraphInfo.FillColor = Aspose.Pdf.Color.Yellow
g1.Shapes.Add(r)
'draw blue
r = New Aspose.Pdf.Drawing.Rectangle(36, 0, 36, 3 * 72) 'build a blue rectangle that takes up the second 1/2" of our graphics area
r.GraphInfo.FillColor = Aspose.Pdf.Color.Blue
g1.Shapes.Add(r)
'no start building the text lines (Eventually these lines will go all the way from top to bottom....but for now there are only 4 lines needed
'in theory every other line needs to be rotated 180 degrees
'prep text 1 -- zero rotation
r = New Aspose.Pdf.Drawing.Rectangle(0, 0, 72, 7)
r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
t = New Aspose.Pdf.Text.TextFragment("ABC")
t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
t.TextState.ForegroundColor = Aspose.Pdf.Color.Blue
t.TextState.FontSize = 7
r.Text = t
g1.Shapes.Add(r)
'prep text 2 -- 180 rotation -- note that in the results, the text is in the wrong place and is truncated
r = New Aspose.Pdf.Drawing.Rectangle(0, 7, 72, 7)
r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
t = New Aspose.Pdf.Text.TextFragment("DEF")
t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
t.TextState.ForegroundColor = Aspose.Pdf.Color.Red
t.TextState.FontSize = 7
t.TextState.Rotation = 180
r.Text = t
g1.Shapes.Add(r)
'prep text 3 -- zero rotation
r = New Aspose.Pdf.Drawing.Rectangle(0, 14, 72, 7)
r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
t = New Aspose.Pdf.Text.TextFragment("GHI")
t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
t.TextState.ForegroundColor = Aspose.Pdf.Color.Red
t.TextState.FontSize = 7
t.TextState.Rotation = 0
r.Text = t
g1.Shapes.Add(r)
'prep text 4 -- 180 rotation -- note that the only way to fix the problem from line #2 was making the HEIGHT of the rectangle bigger (Which makes no sense, and messes up the alignment)
r = New Aspose.Pdf.Drawing.Rectangle(0, 21, 72, 7 * 3)
r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
t = New Aspose.Pdf.Text.TextFragment("JKL")
t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
t.TextState.ForegroundColor = Aspose.Pdf.Color.Red
t.TextState.FontSize = 7
t.TextState.Rotation = 180
r.Text = t
g1.Shapes.Add(r)
' ----- also note that the background of the text is not transparent (thus showing the blue/yellow below) but is instead BLACK.
p.Paragraphs.Add(g1)
d.Save("c:\test\mat" & rnd.Next & ".pdf")
End Sub