Refactor HTML & PDF writer with composite pattern