Stop MODX from parsing Snippet output?

I have a (rather large) snippet that parses through user-submitted form data and generates a PDF file using the FPDF/FPDI SDKs. Once the PDF is generated in PHP, FPDF streams out the data to the user.

After a LOT of headache and head-scratching trying to figure out why some PDFs were fine and some came out completely garbled, seemingly regardless of PDF version and/or settings. With the help of FPDF support I was finally able to determine that MODX is parsing the PDF code streaming through; if it encounters ‘[[’ anywhere in the code, it ends up removing large chunks of the PDF data.

Long story short, is there a way to tell the MODX parser to stop parsing the output from a snippet, i.e. treat it like raw/binary data?

UPDATE: for what it’s worth, I figured out a workaround (or maybe it’s the only solution), which is to write the file to disk and then use $modx->sendRedirect() to bounce the user to the actual file. I would much rather have the file generated and streamed to the user on the fly, but this will get it done for now.

UPDATE 2: The workaround is probably not going to be a viable solution as it raises certain security problems.

You can end the request completely:

1 Like

YES! That took care of it. THANK YOU!!!

1 Like