彰化一整天的論壇

 找回密碼
 立即註冊
查看: 726|回復: 0

php 合併多個pdf檔案

[複製鏈接]
發表於 2017-3-15 09:14:57 | 顯示全部樓層 |閱讀模式
Merging PDFs using PHP shell_exec command

  1. //location of input and output directory
  2. $datadir = "/var/www/data/";

  3. $outputTiffFileName = $datadir."Merged.pdf";
  4. $fileArray = array($datadir."1.pdf",$datadir."2.pdf",$datadir."3.pdf");

  5. //ghost script command to run
  6. $cmd = "gs -SDEVICE=tiffg4 -r600x600 -sPAPERSIZE=letter -sOutputFile=$outputTiffFileName -dNOPAUSE -dBATCH ";
  7. //Add each pdf file to the end of the command
  8. foreach($fileArray as $file)
  9. {
  10.     $cmd .= $file." ";
  11. }

  12. //Execute the ghost script that merges multiple PDFs and saves the it in the data directory.
  13. $response = shell_exec($cmd);
複製代碼



資料來源: https://phpdave.wordpress.com/20 ... -pdfs-using-php-gs/
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2019-8-25 10:56 , Processed in 0.132869 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表