Hello, we have a problem with z-index since we upgraded to the latest version of pdf, involving text in tables within floating boxes.
Previously (Version 4.0.0.0) text in a table, positioned by floating box would obey the z-index with respect to other floating boxes. However in the current version (Version 6.7.0.0) an image in a floating box with a smaller z-index will obscure the table in a floating box with a higher z-index.
The code below, renders two images within two floaing boxes with z-index 0 and 1 respectively. It also renders text in a table within a third floating box with z-index 2. We expect the text to be on top of both images. However, the image with z-index of 1 ends up on top of the text.
Note: text only in a floating box does correctly render, but text in a table in a floaing box does not.
We require the text to be in the table.
Thanks for your help
class Program {
static void Main(string[] args) {
var pdf1 = new Pdf();
var section = new Section(pdf1);
pdf1.Sections.Add(section);
// Want the Text to be on top of both the images.
PlaceImage(section, 62f, 48.75f, 48.5f, 50f, 0);
PlaceText(section, 68f, 55f, 217.25f, "Why oh why", 2);
PlaceImage(section, 75f, 80.5f, 47.25f, 50f, 1);
pdf1.Save("c:\\temp\\survey.pdf");
}
static private void PlaceImage(Section section, float top, float left, float height, float width, int zIndex) {
var image = new Image();
image.ImageInfo.File = "c:\\temp\\a.gif"; //Note: gif is 100 x 100 pixels
image.ImageInfo.ImageFileType = ImageFileType.Gif;
image.ImageInfo.FixHeight = height;
image.ImageInfo.FixWidth = width;
PlaceParagraphInSection(section, image, top, left, width, zIndex);
}
static private void PlaceText(Section section, float top, float left, float width, String text, int zIndex) {
//Note: Application requires the text to be in a table. Layout purposes.
var myText = new Text(section, text);
var table = new Table();
var row = table.Rows.Add();
var cells = row.Cells.Add();
cells.Paragraphs.Add(myText);
PlaceParagraphInSection(section, table, top, left, width, zIndex);
}
private static void PlaceParagraphInSection(Section section, Paragraph paragraph, float top, float left, float width, int zIndex) {
// Put the paragraphs in a floating box so we can place it around the page, and can set the zindex to handle overlapping boxes.
var fb = new FloatingBox {
Top = top,
Left = left,
PositioningType = PositioningType.PageRelative,
BoxWidth = width,
BackgroundColor = null,
BoxHorizontalPositioning = BoxHorizontalPositioningType.Page,
BoxVerticalPositioning = BoxVerticalPositioningType.Page,
ZIndex = zIndex,
};
// Add supplied paragraph to Floating Box
fb.Paragraphs.Add(paragraph);
// Add the Floating Box to the sections paragraphs
section.Paragraphs.Add(fb);
}
}