我使用以下代码成功连接到版本 1:
<cfhttp method="post"
url="http://do.convertapi.com/Word2Pdf"
result="convertAttempt"
path="#arguments.path#"
file="#arguments.fileToDestination#"
>
<cfhttpparam type="formfield" name="ApiKey" value="xxxxxxx" >
<cfhttpparam type="file" file="#arguments.path#/#arguments.fileToConvert#" name="File" >
</cfhttp>
下面是我尝试使用 version 2 的代码。它将文件写入正确的文件夹,但它不是可读的 PDF。我认为这与base64有关,但不确定。不管怎样,希望有另一个 ColdFusion 用户可以帮助我。然后,我们希望在 ConvertAPI 网站上获得代码示例来帮助其他人。
<cfhttp method="post"
url="http://v2.convertapi.com/docx/to/pdf?Secret=mysecret"
result="convertAttempt"
path="#arguments.path#"
file="#arguments.fileToDestination#"
>
<cfhttpparam type="file" file="#arguments.path##arguments.fileToConvert#" name="File" >
</cfhttp>
最佳答案
默认情况下,ConvertAPI 版本 2 返回 JSON。您需要使用 Base64 解码器对文件进行解码。
为了节省响应时间和带宽,最好将 accept=application/octet-stream
header 添加到请求中,以获得即时二进制响应,而无需任何解码。
关于coldfusion - 将API版本2 docx转换为PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49641167/