PDFSharp.Extensions
PDFSharp.Extensions copied to clipboard
Issue in converting scanned pdf to image
I was trying to convert the attached pdf to an image using page.GetImages() function as described in the example. It is not working.
44.pdf
` static void Main(string[] args) {
string filename = @"C:\Temp\44.pdf";
Console.WriteLine("Processing file: {0}", filename);
using (PdfDocument document = PdfReader.Open(filename, PdfDocumentOpenMode.Import))
{
int pageIndex = 0;
foreach (PdfPage page in document.Pages)
{
int imageIndex = 0;
foreach (Image image in page.GetImages())
{
Console.WriteLine("\r\nExtracting image {1} from page {0}", pageIndex + 1, imageIndex + 1);
// Save the file images to disk in the current directory.
image.Save(String.Format(@"C:\Temp\{0:00000000}-{1:000}.png", pageIndex + 1, imageIndex + 1, Path.GetFileName(filename)), ImageFormat.Png);
imageIndex++;
}
pageIndex++;
}
}
}`