Fix segfault because of margin being outside the document size