douhan0562 2012-03-19 17:39
浏览 167

使用Zend_Pdf编辑版本高于1.4的pdf

I have an application which adds some data to an existing pdf file and saves it as another pdf file. For editing I'm using part of Zend Framework, Zend_Pdf, but it won't work with pdfs with a version greater than 1.4, but the pdf files which I need to edit are sometimes a higher version than 1.4. I can't find any solution which can solve this directly in this PHP application. So do you know some solution which will work fine?

It shows this error when I try to edit the higher version:

Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'PDF file syntax error. Offset - 0x1BC36D. Wrong W dictionary entry. Only type field of stream entries has default value and could be zero length.' in E:\*****Parser.php:236
Stack trace: 
#0 E:\*****Parser.php(460): Zend_Pdf_Parser->_loadXRefTable('1819501')
#1 E:\*****Pdf.php(318): Zend_Pdf_Parser->__construct('./sources/978-8...', Object(Zend_Pdf_ElementFactory_Proxy), true)
#2 E:\*****Pdf.php(267): Zend_Pdf->__construct('./sources/978-8...', NULL, true)
#3 E:\*****pdf.php(21): Zend_Pdf::load('./sources/978-8...')
#4 E:\*****TestApp.php(54): pdf->pdfLoader()
#5 {main} thrown in E:\*****Parser.php on line 236
  • 写回答

1条回答 默认 最新

  • doutang1873 2012-10-23 09:38
    关注

    In PDF version 1.5 the referencing of Objects in PDF-files has changed. As long as a PDF-File in version 1.5 is not saved in a compatible way (using the old version 1.4 referencing besides the new one) there is no way an application that does not understand PDF-version 1.5 can analyze the structure of the Document.

    As far as I know Zend_Pdf only understands PDF up to version 1.4 and currently there is no intention to change that (in Zend-Framwork 1). So no chance to get that going with Zend_Pdf.

    Other libraries like FPDI might be able to read these documents, but that would require a complete rewrite of your code.

    And some other PDF-libraries like PDFlib can not change existing PDF-files. They can create new ones and integrate parts from existing ones (up to Version 1.7), but it is not possible to change an existing file.

    Sorry, but the only solution seems to me to avoid PDF-files higher than version 1.4. Or perhaps when Zend_Pdf is rewritten for Zend_Framework 2 it allows manipulation of higher versions of PDF-files.

    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应