PDFLib (PCos)从PDF中获取图像位置


PDFLib (PCos) get image position from PDF

所以我试图在PDF中使用PHP和PDFlib pCos库获取图像位置。

我可以列出图像并获得图像尺寸,如:

$imgcount = $tet->pcos_get_number($doc, "length:pages[" . $page . "]/images");
for ($im = 0; $im < $imgcount; $im++) {
  $width = $tet->pcos_get_number($doc, "pages[" . $page . "]/images[" . $im . "]/Width"); 
  $height = $tet->pcos_get_number($doc, "pages[" . $page . "]/images[" . $im . "]/Height");
}

但是我怎么得到图像的位置?

已尝试的路径,如:

"pages[" . $page . "]/images[" . $im . "]/Box"
"pages[" . $page . "]/images[" . $im . "]/Box[0]"
"pages[" . $page . "]/images[" . $im . "]/Rect"

没有工作. .我在网上到处搜索,也查看了PDF参考手册。什么都没有. .

有什么建议吗?

要确定图像的位置,必须解析页面内容。这对于多囊卵巢综合征是不可能的。为此,PDFlib提供了名为TET的附加工具:http://www.pdflib.com/products/tet/

请参阅TET手册第8.5章"放置图像的几何"以了解本主题的更多详细信息。但是从您的代码片段来看,您似乎已经在TET中使用了pCOS接口。如果有,请查看相关手册章节。

一个很好的起点可能是TET 4.3样例image_extractor.php,您只需将这些位置添加到以下代码片段中:
      while ($ti = $tet->get_image_info($page) ) {
       /* Report image geometry */
        print("page " . $pageno . ": " .
            (int) $ti->width . "x" .
            (int) $ti->height . "pt [" .
            (int) $ti->x . "x" .
            (int) $ti->y . "], alpha=" .
            $ti->alpha . ", beta=" .
            $ti->beta . "'n");