Fix for issue #1

Check that the current document is defined before to calculate its size.