WordPress的主题PHP到PDF转换错误

我使用WordPress作为CMS。所以有一部分我试图从php生成pdf文件。我正在使用phpToPDF生成pdf文件。我在wordpress的自定义模板页面中这样做, 但遇到此错误:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Wordpress/wp-includes/general- template.php:2942) in /Applications/MAMP/htdocs/Suburban/wp- content/themes/custom theme/phpToPDF.php on line 56

试图从核心php生成pdf, 并且可以正常工作… 但是我的wordpress网站需要它。
这是代码
< ?php /* Template Name:test */ wp_head(); require("phpToPDF.php"); $my_html="< div style=\"display:block; \"> < div style=\"float:left; width:33%; text-align:left; \"> Left Header Text < /div> < div style=\"float:left; width:33%; text-align:center; \"> Center Header Text < /div> < div style=\"float:left; width:33%; text-align:right; \"> Right Header Text < /div> < br style=\"clear:left; \"/> < /div> "; $pdf_options = array( "source_type" => 'php', "source" => $my_html, "action" => 'view', "save_directory" => '', "file_name" => 'pdf_test.pdf'); phptopdf($pdf_options); // echo ("< a href='http://www.srcmini.com/pdf_invoice.pdf'> Download Your PDF< /a> "); wp_footer() ?>

#1【WordPress的主题PHP到PDF转换错误】删除wp_head(); 和wp_footer()修复了此错误

    推荐阅读