脚本取现有PDF文件,克隆到输出PDF上的双1/2页格式

时间:2016-04-18 13:45:55

标签: php pdf tcpdf fpdf dompdf

编辑:如果涉及任何混淆,底部的图像是左侧的纵向布局,右侧的横向布局。这意味着,左侧的pdf内容将被并排克隆到横向格式中。

我目前使用的资源是FPDF,DOMPDF,并且要将TCPDF合并到这个项目中,用PHP编码。

我需要知道是否可以使用任何这些资源或任何其他资源来获取现有的PDF文件并将其克隆到输出PDF的两半页面。关键是最重要的部分是没有边界/边距。

有没有人有一个可以完美执行此操作的脚本?

这是一个图像表示:

Flipped Page

1 个答案:

答案 0 :(得分:1)

看看FDPI(基于FPDF)。 simple demo显示将PDF导入页面的一部分。

我没有使用它,但根据该演示,您应该可以使用以下内容执行您想要的操作:

<?php
require_once('fpdf.php');
require_once('fpdi.php');

// initiate FPDI
$pdf = new FPDI('L');
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("PdfDocument.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 150 mm
$pdf->useTemplate($tplIdx, 10, 10, 150);
// use the imported page and place it at point 400,10 with a width of 150 mm
$pdf->useTemplate($tplIdx, 400, 10, 150);

$pdf->Output();

(注意:这是完全未经测试的,并且宽度以毫米为单位,而定位在PT中这​​一事实使得这最好是粗略估计。)