Make graphics state save/restore and text object begin/end into methods so code similarities between PS and PDF wil become more apparent.