将多个PDF文件连接到单个页面PDF - 使用PHP定位连接 [英] Join multiple PDF files into a single page PDF - positioned join using PHP

查看:161
本文介绍了将多个PDF文件连接到单个页面PDF - 使用PHP定位连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是尝试将单独的PDF连接到具有多个页面的单个PDF。这是尝试从已存在的少数其他PDF创建单页PDF。我需要使用PHP执行此操作,服务器是CentOS。

This is not an attempt to join separate PDFs to one single PDF with multiple pages. It is an attempt to create a single page PDF from few other PDFs that already exists. I need to do this using PHP and the server is CentOS.

我已经基于单个模板生成一组单页PDF文件(使用FPDF)。要求是允许用户混合和匹配现有PDF文件并将它们放在一起以创建单个PDF。

I am already generating a set of single page PDF files based on individual templates (Using FPDF). The requirement is to allow the user to mix and match existing PDF files and position them together to create a single PDF.

我目前的尝试是将PDF转换为图像(使用ghostscript)并使用输出jpegs使用FPDF创建最终PDF。虽然这是可能的,但转换过程中PDF的质量会有所下降。

My current attempt is to convert the PDFs to images (using ghostscript) and use the output jpegs to create the final PDF using FPDF. While this is possible, the quality of the PDF is compromised a little during conversion.

我想知道是否有更好的解决方案我们可以使用?

I would like to know if there is a better solution that we can use?

更新

解决方案不一定是PHP。它很可能不会。我当然可以使用任何可以完成这项工作的命令行工具。示例命令如下:

The solution doesn't have to be PHP. It most probably wont be. I'm certainly up for any commandline tool that can do the job. Example command would be as follows:

$ newtool -o outfile.pdf -s WidthXHeight -i in1.pdf in2.pdf in2.pdf - g p1Xp2 p3Xp4 p5Xp6

以上仅为示例 - 不是真正的命令 - 我只是希望工具具有这种功能。指定输入文件的集合及其在输出文件中的位置。

Above is an example only - not a real command - I just wish if a tool has that kind of functionality. Specify set of input files and their positions on the output file.

推荐答案

我过去做过这个,结合了Ghostscript(用于在较大的空PDF页面上定位现有PDF页面)和pdftk(将两个大小相同的PDF页面叠加/合并为一个新页面)。

I've done this in the past with a combination of Ghostscript (to position an existing PDF page on a larger empty PDF page) and pdftk (to overlay/merge two equally-sized PDF pages into a new one).

有看看这些答案(@Superuser.com),了解其工作原理:

Have a look at these answers (@Superuser.com) to get an idea how this works:

  • Convert PDF 2 sides per page to 1 side per page
  • Using Ghostscript to convert multi-page PDF into single JPG?
  • Freeware to split a pdf's pages down the middle?

我的程序使用命令行和/或脚本。但是,这也可以扩展为使用Ghostscript以编程方式从PHP执行.dll / .so

My procedure uses commandline and/or scripts. However, this could also be extended to do it programmatically from PHP with the Ghostscript .dll/.so

这篇关于将多个PDF文件连接到单个页面PDF - 使用PHP定位连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆