Fix bug with Preview

The preview function had an issue with working on manuals and new
specialist documents. This commit fixes the 2 related bugs and refactors
the preview code to be more reusable between different models.