Fix run time error in generating labels by reverting some cleaned up codes such as using PDFWriter

GCP-9732

Reviewer: Mae Isabelle Turiana