Bug fixes for PDF factory