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 7692477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:51:42+00:00 2026-05-31T20:51:42+00:00

I learned getting the image size using itextsharp pdf the image size is the

  • 0

I learned getting the image size using itextsharp pdf
the image size is the physical dimension before the image was inserted in the pdf.

Dim iwidth As Integer = tg.GetAsNumber(PdfName.WIDTH).IntValue
Dim iheight As Integer = tg.GetAsNumber(PdfName.HEIGHT).IntValue

When I extracted the image is very large, larger than the paper size.

But if you view the image inside the pdf with any pdf reader software, the image is small.

How can I get the designed image size inside the pdf?

Im using this code and I don’t know if is the proper, I don’t know the next think to do.

Dim pdfDesignedImage As iTextSharp.text.pdf.parser.InlineImageInfo

This is my 2nd account, I was wrong on first. Sorry about that.
I hope I can be better using this account.

  • 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-05-31T20:51:43+00:00Added an answer on May 31, 2026 at 8:51 pm

    There’s a poorly named Interface called ITextExtractionStrategy that you can implement that will give you extended information when extracting things from a PDF. I say “poorly named” because although it says “text” it also supports images as well. This interface has 5 methods, 4 of which are text-based and you can just ignore. The method that you are interested in is RenderImage. Below is a full working implementation of this:

    Public Class ImageInfoTextExtractionStrategy
        Implements iTextSharp.text.pdf.parser.ITextExtractionStrategy
    #Region " Extra Methods - Just Ignore "
        Public Sub BeginTextBlock() Implements iTextSharp.text.pdf.parser.IRenderListener.BeginTextBlock
        End Sub
        Public Sub EndTextBlock() Implements iTextSharp.text.pdf.parser.IRenderListener.EndTextBlock
        End Sub
        Public Sub RenderText(renderInfo As iTextSharp.text.pdf.parser.TextRenderInfo) Implements iTextSharp.text.pdf.parser.IRenderListener.RenderText
        End Sub
        Public Function GetResultantText() As String Implements iTextSharp.text.pdf.parser.ITextExtractionStrategy.GetResultantText
            Return Nothing
        End Function
    #End Region
        ''//We'll add all image rectangles to this collection
        Private _AllImageRectangles As New List(Of iTextSharp.text.Rectangle)
        Public ReadOnly Property AllImageRectangles As List(Of iTextSharp.text.Rectangle)
            Get
                Return Me._AllImageRectangles
            End Get
        End Property
        Public Sub RenderImage(renderInfo As iTextSharp.text.pdf.parser.ImageRenderInfo) Implements iTextSharp.text.pdf.parser.IRenderListener.RenderImage
            ''//Get the image's matrix
            Dim m = renderInfo.GetImageCTM()
            Dim w, h, x, y As Single
            ''//Get the various parameters from the matrix
            w = m(iTextSharp.text.pdf.parser.Matrix.I11)
            h = m(iTextSharp.text.pdf.parser.Matrix.I22)
            x = m(iTextSharp.text.pdf.parser.Matrix.I31)
            y = m(iTextSharp.text.pdf.parser.Matrix.I32)
            ''//Turn the parameters into a rectangle
            Me._AllImageRectangles.Add(New iTextSharp.text.Rectangle(x, y, x + w, y + h))
        End Sub
    End Class
    

    To use this subclass we pass it to the (once again poorly named) method iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(). Normally you’d call this method and assign the string result to a variable but in our case we don’t care about the text so don’t. To use it you would do this:

        ''//Path to our pdf with images
        Dim PdfWithImage = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "PdfWithImage.pdf")
        ''//Bind a reader to our PDF
        Dim reader As New PdfReader(PdfWithImage)
        ''//Create an instance of our custom extraction class
        Dim strat As New ImageInfoTextExtractionStrategy()
        ''//Loop through each page in our PDF
        For I = 1 To reader.NumberOfPages
            ''//The GetTextFromPage method does the work even though we are working with images
            iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, I, strat)
        Next
        ''//Get all image rectangles found
        Dim Rects = strat.AllImageRectangles
        For Each R In Rects
            ''//Do something with your rectangles here
        Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting all learned up about binding in WPF. I'm having a lot of
I have a login function in my controller that was getting called before, but
I just started getting into BizTalk at work and would love to keep using
So I just learned about List Comprehensions in python. some of these are getting
I read this question about the error that I'm getting and I learned that
I am getting into integrating my app with LDAP and I just recently learned
Following this tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application), I learned how to save data and do concurrency checks
I keep getting ActivityNotFoundException: Unable to find explicit activity class ... when using Eclipse's
I learned today that NetBeans 6.5 should have an on-the-fly compilation of (single) Java
I learned Java in college, and then I was hired by a C# shop

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.