Hi there
I’m trying to overlay a text paragraph on top of a floating box. Setting the z-index seems to have no effect. From what I understand in the documentation, setting z-index to a negative number ought to put the floating box behind the text paragraph. What am I missing? Below is my code.
Many thanks, Brett
public static void CreateZIndexSample(Stream stream)
{
SetLicense();
var document = new Document();
var page = document.Pages.Add();
// draw the filled box
var width = 100f;
var height = 100f;
var left = 100f;
var top = 100f;
var box = new FloatingBox { Left = left, Top = top, ZIndex = -1 };
var graph = new Aspose.Pdf.Drawing.Graph(width, height);
var shape = new Aspose.Pdf.Drawing.Rectangle(0, 0, width, height)
{
GraphInfo = new GraphInfo
{
Color = Color.Black,
FillColor = Color.Blue
}
};
graph.Shapes.Add(shape);
box.Paragraphs.Add(graph);
page.Paragraphs.Add(box);
// add the text
var builder = new TextBuilder(page);
var fragment = new TextFragment("Hello, world!");
fragment.TextState.Font = FontRepository.FindFont("Helvetica");
fragment.TextState.FontSize = 20;
fragment.ZIndex = 1;
var paragraph = new TextParagraph
{
Position = new Position(page.PageInfo.Margin.Left + left + 20f, page.PageInfo.PureHeight - top),
};
paragraph.AppendLine(fragment);
builder.AppendParagraph(paragraph);
document.Save(stream);
}