我目前正在编写一个代码,使用PDFlib从
http://www.pdflib.com/输出PHP文件中的pdf文件.问题是所有html标记也写在输出文件中.如何能够取消所有这些标签?
这是我的示例代码.
$postVariable = $_POST;
$contentData = "";
foreach($postVariable as $key => $value){
if(is_array($key)){
foreach($key as $key1 => $value1){
$contentData.= $key1 .": ". $value1."";
}
}else{
$contentData.= $key .": ". $value."";
}
}
$testdata = nl2br($contentData);
$pdf = pdf_new();
// open a file
pdf_open_file($pdf, $_SERVER['DOCUMENT_ROOT']."cas".DIRECTORY_SEPARATOR."$filename.pdf");
// start a new page (A4)
pdf_begin_page($pdf, 595, 842);
// Locate Font Directory
$fontdir = "C:\WINDOWS\Fonts";
// Font Name Parameters
pdf_set_parameter($pdf, "FontOutline", "arialMyName=$fontdir\arial.ttf");
// Find Font
$arial = PDF_findfont($pdf,"arialMyName","host",0 );
// Set font size and font name
pdf_setfont($pdf, $arial, 10);
//$arial = pdf_findfont($pdf, "Arial", "host", 1);
//pdf_setfont($pdf, $arial, 10);
// print text
pdf_show_xy($pdf, "TO THE UNIT OWNER",50, 750);
pdf_show_xy($pdf, "Test ext", 50,730);
pdf_show_xy($pdf, "test test", 50,715);
pdf_show_xy($pdf, $contentData, 50,700);
// end page
pdf_end_page($pdf);
// close and save file
pdf_close($pdf);
并且示例输出是:
对单位所有者
测试文本
测试一下
类型:公寓**** var_name:**** var_company:**** var_date:****提交:保存并下载< 它忽略了html标签,并将其包含在内容中. 有没有其他方法可以使用我正在使用的库(PDFlib)将HTML打印到PDF. 谢谢. 问候,
Resty