如何在wordpress上下载PDF格式的内容

I have a custom select query data and i want to export those data in to downloadable pdf
How can i do this? Those selected query data changes according to the users. This data is like invoice any idea about this?

I used below code but i can't open the pdf.

 $filename = "tender_report_" . date('Ymd') . ".pdf";

  header("Content-Disposition: attachment; filename=\"$filename\"");
  header("Content-Type: application/pdf");