長方形の中に、左寄せで文字を表示させたいのですが、下記ソースコードのように記述したところ、添付CannotHorizontalAlignmentLeft.pdf (95.4 KB)
のように長方形の中央に文字列が配置されます。
ご確認、および、他に対応方法があればを教えて頂けないでしょうか?
■使用バージョン
Aspose.Pdf for .NET 18.10.0.0
■ソースコード(VB.Net)
'Instantiate the License class
Dim license As License = New License()
'Pass only the name of the license file embedded in the assembly
license.SetLicense(“Aspose.Pdf.lic”)
Dim doc As Document = New Document(sourcePath)
' Create Graph object with certain dimensions
Dim graph As Drawing.Graph = New Drawing.Graph(doc.PageInfo.Width, doc.PageInfo.Height)
' Add graph object to paragraphs collection of Page instance
doc.Pages(1).Paragraphs.Add(graph)
Dim textColor As Color = Color.FromArgb(255, 255, 255)
Dim backColor As Color = Color.FromArgb(255, 0, 128)
' Rectangle
Dim backRectangle As Drawing.Rectangle = New Drawing.Rectangle(225, 208, 125, 10)
backRectangle.GraphInfo.Color = backColor
backRectangle.GraphInfo.FillColor = backColor
' add Text
Dim fragment1 As Text.TextFragment = New Text.TextFragment("Left")
fragment1.TextState.Font = Text.FontRepository.FindFont("MS Gothic")
fragment1.TextState.FontSize = 10
fragment1.TextState.ForegroundColor = textColor
backRectangle.Text = fragment1
backRectangle.Text.HorizontalAlignment = HorizontalAlignment.Left
graph.Shapes.Add(backRectangle)
doc.Save(outputPdfPath)