Hi
Aspose PDF. NET 22.5
I create a custom layer with an image on the page and save the file - it works
var nameLayer = "Template_" + templateName;
if (page.Layers != null && page.Layers.Count > 0)
{
var oldLayer = page.Layers.FirstOrDefault(l => l.Name == nameLayer);
if (oldLayer != null)
page.Layers.Remove(oldLayer);
}
setImageSize(s);
FileStream imageStream = new FileStream(s.filepath, FileMode.Open);
page.Resources.Images.Add(imageStream);
var marginY = page.MediaBox.Height - s.xyp.h - s.xyp.y;
Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(s.xyp.x, marginY, s.xyp.x + s.xyp.w, marginY + s.xyp.h);
Matrix matrix = new Matrix(new double[] { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY });
Layer layer = new Layer(nameLayer + page.Number.ToString(), nameLayer);
layer.Contents.Add(new Aspose.Pdf.Operators.GSave());
layer.Contents.Add(new Aspose.Pdf.Operators.ConcatenateMatrix(matrix));
XImage ximage = page.Resources.Images[page.Resources.Images.Count];
layer.Contents.Add(new Aspose.Pdf.Operators.Do(ximage.Name));
layer.Contents.Add(new Aspose.Pdf.Operators.GRestore());
page.Layers = new List<Layer>();
page.Layers.Add(layer);
imageStream.Close();
But when I read this file again, I see my custom layer is there, but its Contents are empty (Layer.Contents.Count= 0). How do I read the contents of my custom layer?