Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:32:37+00:00 2026-06-11T00:32:37+00:00

I have a pdf document containing several images. I want to retrieve names of

  • 0

I have a pdf document containing several images.

I want to retrieve names of these images.

How to achieve this using either iText or pdfbox?

I know that ExtractImages extracts images from PDF. I feel that this will somewhere have the functionality to fetch name of the image. However, I don’t know the usage of ExtractImages.

The actual problem to fetch names of PDF is to use it to compress these images to reduce the size of the pdf. Is my approach correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:32:38+00:00Added an answer on June 11, 2026 at 12:32 am

    What you can get with pdfbox is the key of the image and its suffix (type). You can also save that image.

        String prefix = new File(pdfFilename).getName();
        prefix = prefix.substring(0, prefix.indexOf(".pdf"));
    
        PDDocument document = null;
    
        try
        {
            document = PDDocument.loadNonSeq(new(pdfFilename), null); // use non-seq parser is better
    
            List<PDPage> pages = document.getDocumentCatalog().getAllPages();
            System.out.println(pdfFilename + ": Total pages: " + pages.size());
            int p = 0;
            for (PDPage page : pages)
            {
                ++p;
                PDResources resources = page.getResources();
                Map<String, PDXObjectImage> imageResources = resources.getImages();
                for (String key : imageResources.keySet())
                {
                    PDXObjectImage objectImage = imageResources.get(key);
                    System.out.printf("image key '%s': %d x %d, type %s%n", key, objectImage.getHeight(), objectImage.getWidth(), objectImage.getSuffix());
    
                    // write that image
                    String fname = String.format("%s-%04d-%s", prefix, p, key);
                    objectImage.write2file(fname);
                }
            }
        }
        // put catch here
        document.close();
    

    However this won’t help you unless you are sure that all these images were converted directly to PDF, i.e. without rotation, translation or scaling. If you need this, then you might want to have a look at the PrintImageLocations.java example in the PDFBOX src download.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several PDF documents containing maps. Which one of these is the best
I have PDF documents containing several images/pages of scanned documents. Their (OCR-produced) text content
I have the text from a PDF document available to me, and I want
I'm using iTextSharp to print a PDF document. Everything goes ok until I have
I have a Filetable containing many different document types (.doc;.pdf;.xls etc). I am writing
I m embeding a pdf document into my html code. For this i have
I have a requirement where i want to load pdf document in a web
Find the field names of inputtable form fields in a PDF document? I have
I have a PDF document to which I want to add internal hyperlinks. Specifically,
I have a PDF document in my app which I want to allow users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.