/// <summary> /// Gets the order of the layers in which they will be displayed in the layer view panel, /// including nesting. /// </summary> private static void GetOCGOrder(PdfArray order, PdfLayer layer) { if (!layer.IsOnPanel()) { return; } if (layer.GetTitle() == null) { order.Add(layer.GetPdfObject().GetIndirectReference()); } IList <PdfLayer> children = layer.GetChildren(); if (children == null) { return; } PdfArray kids = new PdfArray(); if (layer.GetTitle() != null) { kids.Add(new PdfString(layer.GetTitle(), PdfEncodings.UNICODE_BIG)); } foreach (PdfLayer child in children) { GetOCGOrder(kids, child); } if (kids.Size() > 0) { order.Add(kids); } }
/// <summary>Adds a new layer to the current layer membership.</summary> /// <param name="layer">the layer to be added</param> public virtual void AddLayer(PdfLayer layer) { PdfArray layers = GetPdfObject().GetAsArray(PdfName.OCGs); if (layers == null) { layers = new PdfArray(); GetPdfObject().Put(PdfName.OCGs, layers); } layers.Add(layer.GetPdfObject()); layers.SetModified(); }
/// <summary>Adds a new operand to the current visibility expression.</summary> /// <param name="layer">the layer operand to be added.</param> public virtual void AddOperand(PdfLayer layer) { GetPdfObject().Add(layer.GetPdfObject()); GetPdfObject().SetModified(); }