Preparing document layout