当前位置: 首页>>代码示例>>Java>>正文


Java PDXObjectImage.getRGBImage方法代码示例

本文整理汇总了Java中org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage.getRGBImage方法的典型用法代码示例。如果您正苦于以下问题:Java PDXObjectImage.getRGBImage方法的具体用法?Java PDXObjectImage.getRGBImage怎么用?Java PDXObjectImage.getRGBImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage的用法示例。


在下文中一共展示了PDXObjectImage.getRGBImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPDFBox

import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage; //导入方法依赖的package包/类
@Test
public void testPDFBox() throws IOException {

	PDDocument document = null;

	File file = new File(JazzPDFReader.PDF_TESTE);

	document = PDDocument.load(file);

	List pages = document.getDocumentCatalog().getAllPages();

	for (Object object : pages) {

		PDPage page = (PDPage) object;
		PDResources resources = page.getResources();
		Map images = resources.getImages();
		if (images != null) {
			Set keySet = images.keySet();
			Iterator imageIter = keySet.iterator();
			while (imageIter.hasNext()) {
				String key = (String) imageIter.next();
				PDXObjectImage image = (PDXObjectImage) images.get(key);
				BufferedImage bufferedImage = image.getRGBImage();

				ImageIO.write(bufferedImage, "jpg", new File("/home/darcio/Desktop/ExamePDFTeste/pdfbox/imgFromPDFBOX" + System.currentTimeMillis() + ".jpg"));
			}
		}
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:30,代码来源:JazzPDFReader.java

示例2: processResources

import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage; //导入方法依赖的package包/类
/**
 *
 *
 * @param resources
 *
 * @throws IOException
 */
private void processResources(PDResources resources, TikaImageHelper helper)
throws IOException {
  if (resources == null)
    return;

  try {
    Map<String, PDXObject> xobjects = resources.getXObjects();
    if (xobjects != null) {
      Iterator<String> xobjectIter = xobjects.keySet().iterator();
      while (xobjectIter.hasNext()) {
        String key = xobjectIter.next();
        PDXObject xobject = xobjects.get(key);
        // write the images
        if (xobject instanceof PDXObjectImage) {
          PDXObjectImage image = (PDXObjectImage) xobject;
          if (ImageTools.imagePerPageRatioValid(imageCount++, pageCount)
              && ImageTools.imageSizeValid(image.getHeight(), image.getWidth())) {
            BufferedImage buffImage = image.getRGBImage();
            helper.addImage(buffImage);
          }
        }
        // maybe there are more images embedded in a form object
        else if (xobject instanceof PDXObjectForm) {
          if (ImageTools.imagePerPageRatioValid(imageCount, pageCount)) {
            PDXObjectForm xObjectForm = (PDXObjectForm) xobject;
            PDResources formResources = xObjectForm.getResources();
            processResources(formResources, helper);
          }
        }
      }
    }
  } catch (Exception e) {
    LOG.info("Shit happened", e);
  }

}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:44,代码来源:PDF2XHTML.java


注:本文中的org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage.getRGBImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。