Delete unmanaged file after download?
// Generate pdf card.
$file_path = $crm_card-&gt;generatePdfCard();
$filename = basename($file_path);
$headers = [
  'Content-Type' =&gt; 'application/octet-stream',
  'Content-Disposition' =&gt; 'attachment; filename="' . $filename . '"',
  'Content-Length' =&gt; filesize($file_path),
];

$binary_file_response = new BinaryFileResponse($file_path, 200, $headers);
$binary_file_response-&gt;deleteFileAfterSend(TRUE);

return $binary_file_response;