title: extract images from pdf document
body: <p>I know similar questions have been asked before, however, they are hideously out of date (some going back to 2006).</p>
  
  <p>I have a .net 3.5 app (w/ iTextSharp 5) I am converting to .net core (iText 7) which extracts signatures from FedEx tracking documents, sent in a byte[] array via a SOAP service. This code has worked very well for many years now with minor updates. There are a couple of images in the PDF document returned from Fedex but the signature block is not the 110x46 image (which is the fedex logo in the pdf file, hence why I skip over it.)</p>
  
  <pre><code>PdfReader pdf = new PdfReader(FedexData);
  
  for(Int32 iPage = 1; iPage &lt;= pdfReader.NumberOfPages; iPage++)
  {
     PdfDictionary pg = pdf.GetPageN(iPage);
     PdfDictionary res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));
     PdfDictionary xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));
  
     foreach(PdfName name in xobj.Keys)
     {
        PdfObject obj = xobj.Get(name);
  
        if(obj.IsIndirect())
        {
            PdfDictionary tg = (PdfDictionary)PdfReader.GetPdfObject(obj);
            String width = tg.Get(PdfName.WIDTH).ToString();
            String height = tg.Get(PdfName.HEIGHT).ToString();
            String decode = tg.Contains(PdfName.DECODEPARMS) ? tg.Get(PdfName.DECODEPARMS).ToString() : "";
            String bitspercomponent = tg.Contains(PdfName.BITSPERCOMPONENT) ? tg.Get(PdfName.BITSPERCOMPONENT).ToString() : "";
            String colorspace = tg.Contains(PdfName.COLORSPACE) ? tg.Get(PdfName.COLORSPACE).ToString() : "";
            if(width != "110" &amp;&amp; height != "46" &amp;&amp; bitspercomponent != "1")
            {
                  ImageRenderInfo imgRI = ImageRenderInfo.CreateForXObject(new GraphicsState(), (PRIndirectReference)obj, tg);
                  PdfImageObject image = imgRI.GetImage();
                  Image dotnetImg = image.GetDrawingImage();
  
                  if(dotnetImg != null)
                  {
                  // process image and update database
  </code></pre>
  
  <p>Suffice to say this code doesn't work with iText7. I attempted to port some of it but I do not seem to be getting the images.... so I'm clearly doing something incorrect and its my own ignorance of the iText7 functions which do not seem to offer downward compatibility with the older library.</p>
  
  <p>Can someone point me to a tutorial for iText7 which deals with extracting the images stored in a PDF file? I have found tutorials on how to extract a PDF as an image (not what I want), how to store images in a PDF document (opposite of what I want), and similar questions with answers are based on older libraries which no longer function.</p>
  
  <p>Thanks,
  Vin</p>