You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tom (JIRA)" <ji...@apache.org> on 2010/02/19 07:03:28 UTC

[jira] Commented: (PDFBOX-616) Invalid Images Returned

    [ https://issues.apache.org/jira/browse/PDFBOX-616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12835600#action_12835600 ] 

Tom commented on PDFBOX-616:
----------------------------

If you get the available image readers in ImageIO chances are high that TIFF is missing. Try adding jai_core (1.1.3) and jai_imageio (1.2) to the classpath.

> Invalid Images Returned
> -----------------------
>
>                 Key: PDFBOX-616
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-616
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 0.8.0-incubator
>         Environment: Multiple (Windows)
>            Reporter: James A. Thomas
>         Attachments: TIFFimageProblem.pdf
>
>
> When getting images from a PDF document using PDXObjectImage (code fragment below), it returns an image with invalid characteristics.  The PDXObjectImage is not null, but attributes like .getColorSpace() return null.  The image has a height and width, but the getRGBImage() method returns null.
> This happens on EVERY image of the attached file.  Code fragment and output is shown below.  
> If I use the write2file() method of PDXObjectImage to write out the image to a fil, then I get a valid image.  (At least, it displays fine.)
> Code Fragment:
>                 // Get a list of pages from the input PDF document
>                 List pages = InputDoc.getDocumentCatalog().getAllPages();
>                 // Process each page
>                 int i = 0;
>                 for (Object obj : pages)
>                 {
>                     String Barcode = null;
>                     i++;
>                     PDPage page = (PDPage)obj;
>                     // Get the image on the page and process it
>                     PDResources resources = page.getResources();
>                     Map images = resources.getImages();
>                     System.out.println("Found " + images.size() + " images on Page " + i);
>                     if( images != null )
>                     {
>                         Iterator imageIter = images.keySet().iterator();
>                         while ( imageIter.hasNext() )
>                         {
>                             String key = (String)imageIter.next();
>                             System.out.println("key = " + key);
>                             PDXObjectImage image = (PDXObjectImage)images.get( key );
>                             if (image != null)
>                             {
>                                 System.out.println("Image subtype = " + image.SUB_TYPE.toString());
>                                 System.out.println("Image suffix = " + image.getSuffix());
>                             System.out.println("PDX image has height = " + image.getHeight()
>                                                 + " and width " + image.getWidth());
>                             // Convert image to a Buffered Image, so we can
>                             // look for a barcode and decode it
>                             BufferedImage RGBimage = image.getRGBImage();
>                             if (RGBimage == null)
>                                 System.out.println("RGBimage is null");
>                             }
>                         }
>                     }
> Output:
> Found 1 images on Page 1
> key = Obj3
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 2
> key = Obj8
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 3
> key = Obj13
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 4
> key = Obj18
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 5
> key = Obj23
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 6
> key = Obj28
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 7
> key = Obj33
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 8
> key = Obj38
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 9
> key = Obj43
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null
> Found 1 images on Page 10
> key = Obj48
> Image subtype = Image
> Image suffix = tiff
> PDX image has height = 2335 and width 1651
> RGBimage is null

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.