extract method for creating pdf