How to extract images from pdf in c #?

How to extract image from pdf file using c #? Thank!

+3
source share
2 answers

You can use iTextSharp . Here is an example .

+1
source

The Docotic.Pdf library can be used to extract images from PDF files.

Here is an example that shows how to iterate over pages and extract all the images from each PDF page:

static void ExtractImagesFromPdfPages()
{
    string path = "";
    using (PdfDocument pdf = new PdfDocument(path))
    {
        for (int i = 0; i < pdf.Pages.Count; i++)
        {
            for (int j = 0; j < pdf.Pages[i].Images.Count; j++)
            {
                string imageName = string.Format("page{0}-image{1}", i, j);
                string imagePath = pdf.Pages[i].Images[j].Save(imageName);
            }
        }
    }
}

The library will not overflow images. It will save them exactly the same as in PDF.

Disclaimer: I work for Bit Miracle, a library provider.

+1
source

Source: https://habr.com/ru/post/1732318/


All Articles