0
以下片段来自“http://pdfx.cs.man.ac.uk/usage”。这个非常棒的工具,它将PDF中的科学论文转换为xml。Unix命令行CURL等效于CURL
curl --data-binary @"/path/to/my.pdf"
-H "Content-Type: application/pdf"
-L "http://pdfx.cs.man.ac.uk"
此代码是unix命令行代码,我希望它的PHP版本。我曾尝试
$pdfFile = fopen('jucs_18_05_0623_0649_hasan.pdf', 'r');
$fileSize = filesize ('jucs_18_05_0623_0649_hasan.pdf');
$url="http://pdfx.cs.man.ac.uk";
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $pdfFile);
curl_setopt($ch, CURLOPT_INFILESIZE, $fileSize);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$fp = fopen("test.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
if (! $res = curl_exec($ch))
echo "Error: ".curl_error($ch);
else {
echo "Success";
}
curl_close($ch);
的问题是输出到的test.xml是索引文件的HTML代码,而不是提供物品的转换XML版本。
提前
非常感谢它的工作.... – Shahid