Fix invalid cast in Page.Rotation.get()
General-Purpose PDF Library for Java and .NET
Status: Beta
Brought to you by:
stechio
Similar to [BUG:67], occasionally a PDF will have the Rotation value as a PdfReal instead of the expected PdfInteger. This causes an InvalidCastException upon fetching the Rotation value.
To reproduce: load provided PDF and access file.Document.Pages[0].Rotation
To fix: Cast to IPdfNumber and change RotationEnumExtension to accept IPdfNumber as the first parameter, instead of PdfInteger.
Unsure if specifying rotation as a Real is technically allowed by the spec.
Have not looked into Java side of the code for this, but I would expect it to have a similar bug and fix.
Patch file attached.
Your sample's notation is abusive because page rotation should be expressed as an integer multiple of 90; nonetheless, in accordance with viewers like Acrobat which resiliently tolerate such flaws, your patch is welcomed.
Fixed on 0.1.2-Fix branch (rev 198) and 0.2.0 trunk (rev 199).
thank you