PDF to HTML and HTML to PDF solution in php

大憨熊 提交于 2019-12-13 01:59:24

问题


I need to convert a PDF document to HTML and after editing the html I then convert this HTML to PDF . I use 'pdftohtml' ubuntu command (pdftohtml - program to convert pdf files into html, xml and png images) like PHP code below

<?php $output = shell_exec('pdftohtml create.pdf updated.html'); ?>

It convert the whole document successfully but it pass all image in top of the page. Can anyone help me to do this job ?


回答1:


  • You can preserve the layout of your document (headers, footers, paging, etc.) from the original PDF file in the converted html file using the “-layout” flag.

    $output = shell_exec('pdftohtml -layout create.pdf updated.html');
    
  • If you want to only convert a range of pages in a PDF file, use the “-f” and “-l” (a lowercase “L”) flags to specify the first and last pages in the range you want to convert.

    $output = shell_exec('pdftohtml -f 5 -l 9 create.pdf updated.html');
    
  • To convert a PDF file that’s protected and encrypted with an owner password, use the “-opw” flag (the first character in the flag is a lowercase letter “O”, not a zero).

    $output = shell_exec('pdftohtml -opw ‘password’ create.pdf updated.html');
    

Source



来源:https://stackoverflow.com/questions/35008183/pdf-to-html-and-html-to-pdf-solution-in-php

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