public void Write(PdfLiteral value) { WriteSeparator(CharCat.Character); WriteRaw(value.Value); this.lastCat = CharCat.Character; }
/// Converts the specified value to XMatrix. /// If the value not exists, the function returns an identity matrix. /// If the value is not convertible, the function throws an InvalidCastException. public XMatrix GetMatrix(string key, bool create) { XMatrix value = new XMatrix(); object obj = this[key]; if (obj == null) { if (create) this[key] = new PdfLiteral("[1 0 0 1 0 0]"); // cannot be parsed, implement a PdfMatrix... return value; } if (obj is PdfReference) obj = ((PdfReference)obj).Value; PdfArray array = obj as PdfArray; if (array != null && array.Elements.Count == 6) { value = new XMatrix(array.Elements.GetReal(0), array.Elements.GetReal(1), array.Elements.GetReal(2), array.Elements.GetReal(3), array.Elements.GetReal(4), array.Elements.GetReal(5)); } else if (obj is PdfLiteral) { throw new NotImplementedException("Parsing matrix from literal."); } else throw new InvalidCastException("Element is not an array with 6 values."); return value; }