有人可以告诉我如何修复这个字符集来阅读我在这个pdf中的内容。显然出现了问题,因为当文件名是.html并且取出coldfusion并且元字符集是utf-8时,此信息有效。有人请告诉我如何纠正这个问题我对coldfusion很新,我相信问题在于我缺乏知识。任何帮助将不胜感激!
我的结果:
http://jsfiddle.net/yntz3n8w/1/
我想要完成的任务:http://www.flhsmv.gov/dmv/forms/BTR/82040.pdf
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/pdf">
<cfheader name="Content-Disposition" value="attachment;filename=test.pdf">
<cfdocument format="PDF" localurl="yes"
marginTop=".25" marginLeft=".25" marginRight=".25" marginBottom=".25"
pageType="custom" pageWidth="8.5" pageHeight="10.2">
<cfoutput><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PDF Export Example</title>
</head>
<body>
</body>
</html>
</cfoutput>
</cfdocument>
答案 0 :(得分:0)
试试这个基本订单。这是我在我的一个文件中的方式,它可以正常工作:
<cfdocument format="PDF" filename="name.pdf" overwrite="Yes">
<html>
...
</html>
</cfdocument>
<cfheader name="Content-Disposition" value="attachment;filename=name.pdf">
<cfcontent type="application/octet-stream" file="#expandPath('.')#\name.pdf" deletefile="Yes">
答案 1 :(得分:0)
它对我来说很好。但是,如果您在实际的.cfm
文件中硬编码 UTF-8字符,请尝试使用脚本顶部的<cfprocessingdirective pageencoding="utf-8">
。这指示CF引擎内容是UTF-8编码的,因此字符处理正确。
<强>更新强>
听起来你的最终目标是实际填充pdf表格。在这种情况下,您可能不需要在HTML中重新创建整个事物并将其转换为PDF。假设网站允许,只需抓取pdf表单的副本,然后使用cfpdfform
填充它。
使用<cfpdf action="read"..>
获取表单中各个字段的列表并将其转储到屏幕上。
<cfpdfform action="read" source="c:/path/to/82040.pdf" result="data" />
<cfdump var="#data#" />
一旦知道了需要填充的字段的名称,只需使用具有正确字段名称/值的cfpdfform
即可。例如,我快速查看了该表单并提供了此代码段,其中填充了两个字段:所有者姓名和所有者电子邮件:
<!--- for demo purposes, display on screen --->
<cfpdfform action="populate" source="c:/path/to/82040.pdf">
<cfpdfformparam name="owner name" value="John Adams">
<cfpdfformparam name="owner email" value="jadams@example.com">
</cfpdfform>