/// <summary>Returns the value associated to this key as a Float.</summary> /// <remarks>Returns the value associated to this key as a Float. If the value isn't a Pdfnumber, null is returned. /// </remarks> /// <param name="key">the key of which the associated value needs to be returned</param> /// <returns>Float associated with this key</returns> public virtual float?GetAsFloat(PdfName key) { PdfNumber number = GetAsNumber(key); float? floatNumber = null; if (number != null) { floatNumber = number.FloatValue(); } return(floatNumber); }
public virtual Rectangle GetPageSize() { PdfArray box = GetPdfObject().GetAsArray(PdfName.MediaBox); if (box == null || box.Size() != 4) { throw new ArgumentException("MediaBox"); } PdfNumber llx = box.GetAsNumber(0); PdfNumber lly = box.GetAsNumber(1); PdfNumber urx = box.GetAsNumber(2); PdfNumber ury = box.GetAsNumber(3); if (llx == null || lly == null || urx == null || ury == null) { throw new ArgumentException("MediaBox"); } return(new Rectangle(Math.Min(llx.FloatValue(), urx.FloatValue()), Math.Min(lly.FloatValue(), ury.FloatValue ()), Math.Abs(urx.FloatValue() - llx.FloatValue()), Math.Abs(ury.FloatValue() - lly.FloatValue()))); }