Frequently Asked Question:
Extract images from a PDF
Question
Can I extract images from a PDF using Quick PDF Library?
Answer
Yes, you can extract embedded images from a PDF and save them to disk. I've included some sample C# code below that demonstrates how to do this.
Remember you need to first initiate the library and unlock it using your license key, before you can use the code below. Also, this code uses the direct access functions, you can use the regular functions for this task as well.
//Open PDF File to Extract Images
int Handle = pdf.DAOpenFile("C:\\images.pdf", null);
// Get Reference of First Page of the PDF File
int ImageRef = pdf.DAFindPage(Handle, 1);
// Get Image list for Page 1
int ImageList = pdf.DAGetPageImageList(Handle, ImageRef);
// Get Count of images on Page 1 of PDF File
int ImageCount = pdf.DAGetImageListCount(Handle, ImageList);
// Store All images of page 1 in separate file
for (int i = 1; i <= ImageCount; i++)
{
pdf.DASaveImageDataToFile(Handle, ImageList, i, "C:\\Extracted_Image" + Convert.ToString(i) + ".bmp");
}