TCPDF - How do I extract pages form a PDF?

半世苍凉 提交于 2019-12-23 14:04:11

问题


I read somewhere that TCPDF was capable of splitting a PDF into individual pages or images. But there's no mention of this in the documentation or an example of how to do it. Can anyone shed some light on this and if it does't recommend a PHP based one I could use to achieve this.

I'm trying to split a large PDF into high res images.


回答1:


AFAIK this is not possible with pure TCPDF - you can combine it with fpdi (V 1.2.1 and up!) to achieve this.

Other option to do what you want (with explanations, sample source etc.):

  • fpdf together with fpdi
  • http://metacpan.org/pod/PDF::Reuse (perl-based)
  • http://metacpan.org/pod/PDF::Extract (perl-based)
  • http://www.pdflabs.com/docs/pdftk-man-page/ (commandline-based)



回答2:


Here's an ugly little PHP script I run on the command line to 'explode' large multipage PDF files using pdftk

click to see phpburst php script

I created it about 5 years ago, and I'm sure it could be made much prettier, but it works.

pdftk is unfortunately a bit dated. If you use file encryption from a recent version of Adobe Acrobat you'll have to 'downgrade' any passwords to older levels, or pdftk won't be able to open them. The script here does not include username/password support, but basically if you edit the two lines which read

  $command = "pdftk " . $filePath . " cat 3-end output " . $pagesFilePath;

and add

  input_pw yourpassword

in front of cat, it will read most encrypted/password protected PDFs.



来源:https://stackoverflow.com/questions/6934960/tcpdf-how-do-i-extract-pages-form-a-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!