我试图添加一个现有的PDF (否则创建)到PDF创建使用FPDF使用FPDI。它似乎对大多数PDF都有效,但我得到了以下错误:
FPDF error: Unable to find xref table.经过一些测试后,我发现如果我使用一个PDF版本的1.4或更低(Acrobat v5或更低),它似乎是可行的。查看文件,似乎是因为不同的PDF格式。
对此是否有工作或解决方案?我可能有10个000+ PDF上传用户,一些新的工作,其中一些没有。令人讨厌的是,FPDI只是死了,而不是导致某种错误,甚至返回false
我现在能想到的唯一解决方案是解析PDF文件的第一行以确定版本,并且只添加那些能够工作的版本。
编辑:
我还在Zend_Pdf中尝试了这一点,它使用附带的演示文件获得了以下结果:
Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Cross-reference streams are not supported yet.' in /Volumes/Documents/temp/ZendFramework-1.7.7/library/Zend/Pdf/Parser.php:331
Stack trace:
#0 /Volumes/Documents/temp/ZendFramework-1.7.7/library/Zend/Pdf/Parser.php(455): Zend_Pdf_Parser->_loadXRefTable('116')
#1 /Volumes/Documents/temp/ZendFramework-1.7.7/library/Zend/Pdf.php(297): Zend_Pdf_Parser->__construct('/Volumes/Docume...', Object(Zend_Pdf_ElementFactory_Proxy), true)
#2 /Volumes/Documents/temp/ZendFramework-1.7.7/library/Zend/Pdf.php(250): Zend_Pdf->__construct('/Volumes/Docume...', NULL, true)
#3 /Volumes/Documents/temp/ZendFramework-1.7.7/demos/Zend/Pdf/demo.php(37): Zend_Pdf::load('/Volumes/Docume...')
#4 {main}
thrown in /Volumes/Documents/temp/ZendFramework-1.7.7/library/Zend/Pdf/Parser.php on line 331不可能解析大于1.4的PDF吗?
发布于 2011-02-13 05:30:20
我发现使用商业版的FPDI PDF-Parser解决了我的问题。我已经使用它一年了,没有任何PDF是不能解析的(除非PDF已经损坏或者发生了其他奇怪的事情)。
发布于 2009-07-23 23:41:43
您可以在TCPDF中使用FPDI,它将生成并读取版本1.7PDF。
见用于PDF的TCPDF - PHP类。
编辑
最近,我在FPDI和TCPDF中遇到了使用不同版本和格式的PDF的问题,我可以确认1.4以上的PDF版本被击中和错过,有趣的是我有很多1.7个PDF,在1.5和1.6上工作约50/50。
我通过使用GhostScript将所有不可行的PDF文件转换为v1.4来解决这个问题,您可以从命令行中进行exec。使用ps2pdf14从GhostScript lib文件夹。
https://stackoverflow.com/questions/660425
复制相似问题