Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Text Background and Alignment

$
0
0
Hi,
I am using TextFragment and TextState Objects to place Text in my Output PDF File like:

var pos = new Aspose.Pdf.Text.Position[1];
pos[0] = new Aspose.Pdf.Text.Position(0, 0);

// Create TextBuilder for first page
Aspose.Pdf.Text.TextBuilder tb = new Aspose.Pdf.Text.TextBuilder(docu.Pages[1]);
Aspose.Pdf.Text.TextFragment fragment = new Aspose.Pdf.Text.TextFragment("FIRSTPAGE");
// Set the font for TextFragment

fragment.TextState.Font = ts.Font; // is 20
fragment.TextState.FontSize = ts.FontSize; // is attached to this post
fragment.TextState.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
fragment.TextState.BackgroundColor = Color.Red;
fragment.Position = pos[0];

tb.AppendText(fragment);

docu.Save(@"c:\temp\workoutput\orderTest.pdf");

Now i am wondering why my text "FIRSTPAGE" is not fit with the background and the horizontal alignment is not centered. Even when i change the position. 

When i work with TextSegment Objects the output isn't changed.
I have attached the resource files and the font i have used.
Can you give me a hint to correct this? :-)))))

Kind regards
Sebastian

Viewing all articles
Browse latest Browse all 3131

Trending Articles