adapat pdfgen script for subdirectory