简体   繁体   English

如何使用 java 中的 pdfbox 从 pdf 获取图像坐标

[英]How to get image cordinates from pdf using pdfbox in java

I want to get image field from existing pdf and fill it with other image to create new pdf file using pdfbox library in java我想从现有的 pdf 获取图像字段并用其他图像填充它以使用 java 中的 pdfbox 库创建新的 pdf 文件

If your trying to get image coordinates from a PDF you could try PDF Mantis which has a function to extract this information - See example below:如果您尝试从 PDF 获取图像坐标,您可以尝试使用 PDF Mantis来提取此信息 - 请参见下面的示例:

// Load your PDF
PdfMantis pdf = new PdfMantis("/home/example.pdf");

// Get the image index
List <ImageIndex> imageIndex = pdf.getImageIndex().buildIndex();

// Iterate over each entry in the index
for (ImageIndex image : imageIndex) {

    // And then we can get coordinates like so...
    image.getX();
    image.getY();
    image.getHeight();
    image.getWidth();
}

Disclaimer: I am the developer of PDF Mantis.免责声明:我是 PDF Mantis 的开发者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM