Hi,
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,
Hi,
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);
}
Hi David,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.
Thank-you very much. I will test after the next release.
Hi David,
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.