Only set the antialiasing if there is a document
Only create a document when needed