pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lachezar Dobrev <l.dob...@gmail.com>
Subject Re: Wether pdfbox can extract the picture from pdf?
Date Fri, 29 May 2015 09:10:55 GMT
  Yes, it is possible.

  PDDocument pdf = PDDocument.load(input_stream);
  List pages = pdf.getDocumentCatalog().getAllPages();
  for (int pageNo = 0; pageNo < pdf.getNumberOfPages(); pageNo ++)
  {
    PDPage page = (PDPage) pages.get(pageNo);
    PDResources rsc = page.getResources();

    if (rsc == null) continue; // No resources on the page

    Map<String, PDXObjectImage> imgmap = rsc.getImages();
    if (imgmap == null || imgmap.isEmpty()) continue; // No images
    for (PDXObjectImage pdi : imgmap.values())
    {
      BufferedImage img = pdi.getRGBImage();
      // Process the image here.
    }
  }

2015-05-29 11:16 GMT+03:00 单车 <jy_jinchenxi@163.com>:
> I want to extract the picture from pdf. Can you give me some sample code to do it?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message