Image location

  • Lance Wellspring

    I need to parse out all image locations and sizes.  However, my doImage function is never getting hit.  Here is what I have:

    public class myImageExtractor extends CSDeviceAdapter
        private ArrayList<anImage > images = new ArrayList<>();
        protected void doImage(COSName name, PDImage image)
            AffineTransform transform = graphicsState.transform;
            anImage img = new anImage();
            img.positionLeft = transform.getTranslateX();
            img.positionTop = transform.getTranslateY();
            img.width = image.getWidth();
            img.height = image.getHeight();
        public ArrayList<anImage> getImages()
            return images;

    Then, in main:

    //setup extractors
    myImageExtractor imageExtractor = new myImageExtractor();
    PDPage page = (PDPage) node;
    //adjust transforms
    AffineTransform pageTx = new AffineTransform();
    PDFGeometryTools.adjustTransform(pageTx, page);
    //setup interpreter and process
    CSDeviceBasedInterpreter imageEnterpreter = new CSDeviceBasedInterpreter(null, imageExtractor);
    imageEnterpreter.process(page.getContentStream(), page.getResources());

    I also have a custom text extractor setup in the same way, (but overriding onCharacterFound) calling the same functions as the image extractor. 

    Like I said, no images are being found, and my doImage function never gets called.  Any idea what I'm doing wrong?

  • Anonymous - 2012-02-09

    … ask Spock:

    1) no image there
    2) your PDF is using inline images (method "inlineImage")
    3) some of the more sophisticated ways to "hide" images, e.g. in annotations

    As of today, i'm offline. Have fun.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks