Search Kit: Mailing labels don't work
Mailing labels don't work with Search Kit.
Steps to Replicate
- Do a search for contacts in search kit (with a small number of contacts to avoid hitting #3222 (closed)).
- Select 1 or more contacts, select Mailing Labels from Actions.
- Select a label and press Make Mailing Labels.
Expected Result Mailing labels.
Actual Result Spins indefinitely.
This doesn't happen when making PDFs, or if you grab the last HTTP request from the devtools Network tab and open it in a new window.
It happens because TCPDF isn't expecting to be in a "snippet" context at this point - it's just spitting out raw HTML response headers direct to the browser (
$pdf->Output()). "Make documents" uses the more modern `CRM_Utils_PDF_Utils::html2pdf(), which uses DOMPDF or wkHTMLtoPDF, and knows how to handle this. Unfortunately, TCPDF has the mailing label functionality, so we're stuck with it.
How to proceed I could probably make a fix that involves saving the file to disk first - but I think a better fix is to modify the Search Kit "Actions" JS to open the labels in a new window, but I can't find where that happens.