With version 6.1.1, PdfPage.CropBox is defined like this:
Code:
//
// Summary:
// Gets or sets the crop box.
public PdfRectangle CropBox
{
get
{
return base.Elements.GetRectangle("/CropBox", create: true);
}
set
{
base.Elements.SetRectangle("/CropBox", value);
}
}
This means that if the page does not specify a CropBox (a perfectly legal situation), the code incorrectly returns [0 0 0 0] which is not the correct value. According to the PDF specification CropBox is optional and if not specified, it defaults to the value of MediaBox.
There are 3 ways to fix this:
1. Have CropBox return null if the value isn't specified. This is the most correct, but would undoubtedly break much existing code.
2. Have CropBox return MediaBox if the value isn't specified. Probably same problem as fix #1
3. Update the documentation to explain what's happening and that code can call
Code:
page.Elements["/CropBox"]
to get the correct null value if CropBox isn't specified
The same things apply to BleedBox, ArtBox, and TrimBox.