【发布时间】:2014-09-23 10:14:39
【问题描述】:
我们有一个文档要在其布局部分中剪切为单个 pdf 文件: 例如标题 -> 标题.pdf、段落 -> 段落 01.pdf 等。 为了实现这一点,我们使用坐标来了解这些部件的放置位置。 (源文档来自 OCR 工具,保存这些坐标)
我们的问题是:剪切的部分是原始文档的简单副本,但带有蒙版内容,文档边框排列为只留下所需部分可见。 所以生成的文档都是相同的文件大小。 我们如何强制 PDFLib 删除不需要的部分?我希望有一个解决方案。我们尝试了很多修剪框、裁剪框等的组合,但没有结果。
这是我们使用的代码:
$fWidth = 200;//width of document part
$fHeight = 20;//height of document part
$fMinXPoint = 10;//left coordinate x
$fMinYPoint = 10;//left coordinate y
$oPdf = new \PDFLib();
$oPdf->begin_document('', 'optimize=true linearize=true inmemory=true');
$oPdf->set_option('compress=9');
$oPdf->set_option('topdown=true');
$oLoadedDocument = $oPdf->open_pdi_document($sRealFilePath, '');// original pdf
$oPage = $oPdf->open_pdi_page(
$oLoadedDocument,
1,
'clippingarea=crop'
);
$oPdf->begin_page_ext($fWidth, $fHeight, '');
$oPdf->fit_pdi_page($oPage, -$fMinXPoint, -$fMinYPoint, 'position={left top}');
$oPdf->end_page_ext("cropbox={0 0 $fWidth $fHeight}");
$oPdf->close_pdi_page( $oPage );
$oPdf->close_pdi_document( $oLoadedDocument );
$oPdf->end_document('');
【问题讨论】: