"working-draft" NEEDS REFACTORING of toHtml AND toPdf worker