This sample shows how to extract images painted on a PDF page. Docotic.Pdf library provides two different methods for extracting images from PDF files.
Start by calling the PdfPage.GetPaintedImages method to get the collection of images drawn on a page. Then save the images from the collection “as is” and/or “as painted”.
When saving “as is“, the library does not change embedded image bytes at all. The extracted image may look different from what you see on the page. To save an image “as is”, access the PdfImage object using the PdfPaintedImage.Image property, then save the image using one of the PdfImage.Save methods.
When saving “as painted”, the library produces an image that looks the same as on the page. For this, the library applies all transformations specified for the image, like rotation, clipping, scaling, and flipping.
To save an image “as painted”, use PdfPaintedImage.SaveAsPainted methods. Some of these methods allow to specify the desired image format (PNG, JPEG or TIFF) and the resolution for the saved image. By default, the method produces PNG images with 72x72 ppi resolution.
The PdfPaintedImage class also provides the TransformationMatrix and the IsTransformed properties. You can use these properties to check if the image on a page is painted scaled, flipped, or rotated.