We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Floating boxes with zIndex- some table parts falling behind image

Hi,


I have 2 pairs of 2 floating boxes. Each pair has an image in the lower box, and a table in the upper box. The two sets of floating boxes are identical with the exception of their zIndexes.

When the zIndex of the floating box is 0 for image and 1 for table, the table is completely drawn over the image.

When the zIndex of the floating box is 2 for image and 3 for table, parts of the table are drawn under the image. Please run the attached code to see the issue. The issue occurs in every case where the bottom image is something other than 0.

In the example code, I can see the borders going underneath, also cell backgrounds. In my production case I also have the text disappearing but I haven’t been able to replicate that in the example attached.

Hi David,

Thanks for your inquiry. I have tested your shared code using Aspose.Pdf for .NET 11.2.0 and managed to observe the reported ZIndex issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-40175 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

Furthermore in reference to borders and backgrounds issue, We will appreciate it if you please share some sample code to replicate these issues, so we will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hi,


the border issues and cell background issues can be see in the code provided in the first post. I don’t have any additional code.

Hi,


Thanks for your patience.

We have further investigated the issue reported earlier and in order to resolve this issue, please try using following code snippet to generate correct output. Please note that fix will be included in upcoming release of Aspose.Pdf for .NET 11.3.0 which is planned to release in current month. As soon as we have some further updates, we will let you know.

[C#]

Document pdfDocument = new Document();<o:p></o:p>

Page page = pdfDocument.Pages.Add();

int col1 = 0;

int col2 = 220;

int topPos = 50;

DrawFloatingBox(page, DrawRectangle(System.Drawing.Color.MediumPurple), topPos, col1, 100, 2);

DrawFloatingBox(page, DrawTable(System.Drawing.Color.LightGray), topPos + 10, col1 + 10, 100, 3);

DrawFloatingBox(page, DrawRectangle(System.Drawing.Color.MediumPurple), topPos, col2, 100, 0);

DrawFloatingBox(page, DrawTable(System.Drawing.Color.LightGray), topPos + 10, col2 + 10, 100, 1);

pdfDocument.Save(“c:/pdftest/FloatingBoxIssue.pdf”);


private static Aspose.Pdf.Image DrawRectangle(System.Drawing.Color color)<o:p></o:p>

{

int imgHeight = 50;

int imgWidth = 150;

MemoryStream stream = new MemoryStream();

Bitmap b = new Bitmap(imgWidth, imgHeight);

System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b);

g.FillRectangle(new SolidBrush(color), new System.Drawing.Rectangle(0, 0, imgWidth, imgHeight));

b.Save(stream, System.Drawing.Imaging.ImageFormat.Png);

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

image.FixHeight = imgHeight;

image.FixWidth = imgWidth;

image.ImageStream = stream;

return image;

}

private static Aspose.Pdf.Table DrawTable(System.Drawing.Color color)

{

int numOfCols = 5;

int numOfRows = 5;

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

string colWidths = "";

for (int c = 0; c < numOfCols; c++)

{ colWidths += " 30"; }

table.ColumnWidths = colWidths;

table.DefaultCellTextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(color);

Aspose.Pdf.GraphInfo borderTableBorder = new Aspose.Pdf.GraphInfo();

borderTableBorder.Color = Aspose.Pdf.Color.MediumSpringGreen;

borderTableBorder.LineWidth = 5;

table.DefaultCellBorder = new Aspose.Pdf.BorderInfo();

table.DefaultCellBorder = new Aspose.Pdf.BorderInfo();

table.DefaultCellBorder.Top = borderTableBorder;

table.DefaultCellBorder.Right = borderTableBorder;

table.DefaultCellBorder.Bottom = borderTableBorder;

table.DefaultCellBorder.Left = borderTableBorder;

for (int r = 0; r < numOfRows; r++)

{

Aspose.Pdf.Row row = table.Rows.Add();

for (int c = 0; c < numOfCols; c++)

{

Aspose.Pdf.Cell cell = row.Cells.Add("x");

cell.BackgroundColor = Aspose.Pdf.Color.LightGreen;

//

// change properties on cell

//

if (c == 1)

{ cell.DefaultCellTextState.ForegroundColor = Aspose.Pdf.Color.Blue; }

//

// change properties on cell AFTER first clearing and re-adding paragraphs

//

else if (c == 2)

{ cell.Paragraphs.Clear(); cell.Paragraphs.Add(new TextFragment("y")); cell.DefaultCellTextState.ForegroundColor = Aspose.Pdf.Color.Blue; }

//

// change properties on paragraph

//

else if (c == 3)

{ ((TextFragment)cell.Paragraphs[0]).TextState.ForegroundColor = Aspose.Pdf.Color.Blue; }

//

// change properties on paragraph AFTER first clearing and re-adding paragraphs

//

else if (c == 4)

{

cell.Paragraphs.Clear();

cell.Paragraphs.Add(new TextFragment("y"));

((TextFragment)cell.Paragraphs[0]).TextState.ForegroundColor = Aspose.Pdf.Color.Blue;

}

}

}

return table;

}

private static void DrawFloatingBox(Page page, BaseParagraph paragraph, int boxTop, int boxLeft, int boxWidth, int boxZIndex)

{

Aspose.Pdf.FloatingBox fb = new Aspose.Pdf.FloatingBox();

fb.Top = boxTop;

fb.Left = boxLeft;

//fb.BoxWidth = boxWidth;

//Aspose Quirks: it appears that setting the background colour to transparent here is not recommended as for some reason

//aspose ignores alpha value and treats transparent as white. So instead we set background to null.

fb.BackgroundColor = null;

fb.ZIndex = boxZIndex;

page.Paragraphs.Add(fb);

fb.Paragraphs.Add(paragraph);

}

davidpi:
the border issues and cell background issues can be see in the code provided in the first post. I don't have any additional code.
Hi David,

Once new release is published, can you please try using the updated code snippet shared earlier and see if it resolves this problem. In case the problem still persists, please feel free to contact.

Thank-you very much. I will test after the next release.

Hi David,


As soon as the new release becomes available, we will update you within this forum thread.

The issues you have found earlier (filed as PDFNEWNET-40175) have been fixed in Aspose.Pdf for .NET 11.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.