Я хочу повторно автоматизировать этот процесс. К сожалению, службы оптического распознавания символов, которые я пробовал, такие как Azure OCR, Amazon Reckognition и Google Cloud Vision OCR, не обладают такими же возможностями.
Я пытался использовать для этого следующий код:< /p>
Код: Выделить всё
using System;
using System.Collections.Generic;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas.Parser;
using iText.Kernel.Pdf.Canvas.Parser.Listener;
namespace PdfImageDetectionTest
{
class Program
{
public static List GetPagesWithImages(string pdfPath)
{
List pagesWithImages = new List();
// Load the PDF document
using (PdfReader pdfReader = new PdfReader(pdfPath))
using (PdfDocument pdfDocument = new PdfDocument(pdfReader))
{
int totalPages = pdfDocument.GetNumberOfPages();
for (int i = 1; i 0)
{
Console.WriteLine("Pages with images: " + string.Join(", ", pagesWithImages));
}
else
{
Console.WriteLine("No pages contain images.");
}
// Keep console window open
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
public class ImageDetectionListener : IEventListener
{
private bool foundImage = false;
public void EventOccurred(IEventData data, EventType type)
{
if (type == EventType.RENDER_IMAGE)
{
foundImage = true; // Image found!
}
}
public bool HasImage()
{
return foundImage;
}
public ICollection GetSupportedEvents()
{
// Only listen for image rendering events
return new HashSet { EventType.RENDER_IMAGE };
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... a-pdf-file
Мобильная версия