Split PDF file into image files using C # 2008?

In my PDF file, I have a page containing 10 images.

I want to split a PDF file as 10 separate image files and save them in a separate folder.

Please give me an idea or sample solution.

Im using C # 2008.

+3
source share
2 answers

I don’t know if this is still true after a year, but I just did it recently, so I decided that I would answer anyway.

Ghostscript (http://sourceforge.net/projects/ghostscript/) // PS/PDF. %PROGRAMDATA\gs\bin\ ( x86, x64) gsdll32.dll /bin.

, Super PDF2Image Converter (http://www.softwaresigloxxi.com/downloading_superPDF2ImageConverter.html), Pdf2Image.dll . zip /bin.

, PDF :

using Pdf2Image;

-

  const string _filename = "/3.pdf";
  // Instantiate the component
  var p2i = new Pdf2ImageConverter(_filename);

  // Get page count of a PDF file
  int pages = p2i.GetPageCount();
  Response.Write(pages);

  // loops through each page
  for (int i = 1; i < pages; i++)
  {
   // Get size of any page
   int width, height;
   p2i.GetPageSize(i, out width, out height);

   // converts the page to PNG format (returns bitmap object with original size)
   var pdfimage = p2i.GetImage(i, width, Pdf2ImageFormat.PNG);
   pdfimage.Save(string.Format("/{0}.png",i));
   pdfimage.Dispose();
  }

.

+1

, PDF .

, Docotic.Pdf library. , , PDF :

static void ExtractImagesFromPdfPageIntoFolder()
{
    string pathToPdf = "";
    int pageIndex = 0;
    string outputFolder = "";
    using (PdfDocument pdf = new PdfDocument(pathToPdf))
    {
        for (int i = 0; i < pdf.Pages[pageIndex].Images.Count; i++)
        {
            string imageName = string.Format("image{0}", i);
            string outputName = Path.Combine(outputFolder, imageName);
            string savedPath = pdf.Pages[pageIndex].Images[i].Save(outputName);
        }
    }
}

: Bit Miracle, .

+1

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


All Articles