Pretty sure the line number in the error is just a...
# advancedpdf
e
Pretty sure the line number in the error is just a red herring as it doesn't seem to correspond to anything consistent when I make changes in the template. I suspect those two macros specifically because commenting them out like so works great.