I have a project and there is a total of 20,000 files pdf need to extract and all specific data is put in the database by extracting. Also it need to get the pictograms of the data.How to achieve it do I need an API or it will achieve only vy using ASP.net C#?
Loading

Tuhin PaulRank #7 · 71.9K reputationPosted May 3, 2023, 2:41 PM EDT
Extracting data from 20,000 PDF files and saving it in a database can be a time-consuming task. You can use ASP.NET C# to achieve this, but it might be easier to use a third-party API or library to extract the data. There are several options for PDF extraction libraries, such as iTextSharp, PDFBox, and Spire.PDF. These libraries provide various functionalities to extract data from PDF files, such as text, images, tables, and more. You can choose the one that best suits your needs and integrate it into your ASP.NET C# project. As for getting the pictograms of the data, you might need to use a separate API or library that can analyze the extracted data and generate the corresponding pictograms. This will depend on the specific data and pictograms that you need.
Tuhin PaulRank #7 · 71.9K reputationPosted May 3, 2023, 2:43 PM EDT
A code snippet to extract data from PDF files using C#:
using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.Data.SqlClient; namespace PdfDataExtractor { class Program { static void Main(string[] args) { string connectionString = "your_connection_string_here"; string pdfDirectory = "path_to_your_pdf_directory"; // Step 1: Loop through all PDF files in the directory foreach (string pdfFile in Directory.GetFiles(pdfDirectory, "*.pdf")) { // Step 2: Extract text from each PDF file string pdfText = ExtractTextFromPdf(pdfFile); // Step 3: Parse the extracted text and save to database SaveToDatabase(connectionString, pdfText); } } private static string ExtractTextFromPdf(string pdfFile) { string pdfText = string.Empty; using (PdfReader reader = new PdfReader(pdfFile)) { for (int page = 1; page <= reader.NumberOfPages; page++) { pdfText += PdfTextExtractor.GetTextFromPage(reader, page); } } return pdfText; } private static void SaveToDatabase(string connectionString, string pdfText) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand("INSERT INTO YourTable (PdfData) VALUES (@PdfData)", connection); command.Parameters.AddWithValue("@PdfData", pdfText); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } } } }this is just a basic outline and you'll need to customize it to fit your specific needs. For example, you'll need to update the connection string to your own database, modify the SQL query to insert data into your own table, and add code to extract the pictograms from the PDF files.
Leon DRank #851 · 2.6K reputationPosted May 3, 2023, 9:41 PM EDT
Hi Junnil,
You can use Spire.PDF library to achieve this function. It provides various ways to extract data from PDF, such as extracting text from all PDF pages, extracting text from a specific PDF page, extracting text from a specific page area, extracting table data from PDF, extracting images from all PDF pages, and extracting images from a specific PDF page.
Here are some of the articles for your reference:
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/How-to-Extract-Text-from-PDF-Document-with-C-/VB.NET.html
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/How-to-Extract-Image-From-PDF-in-C.html
https://www.e-iceblue.com/Tutorials/NET/Spire.PDF/Program-Guide/Table/C-/VB.NET-Extract-Tables-from-PDF.html
Vishal YelveRank #178 · 13.6K reputationPosted May 5, 2023, 7:38 AM EDT
Hi Junnil,
do refer below links
https://ironpdf.com/blog/using-ironpdf/how-to-extract-data-from-pdf-in-csharp/
https://www.grapecity.com/blogs/how-to-programmatically-extract-data-from-pdf-using-net-c-sharp
https://www.textcontrol.com/blog/2022/06/16/extract-text-and-data-from-pdf-documents-in-csharp/
Marvin ReidRank #1,963 · 746 reputationPosted Jun 8, 2023, 3:45 PM EDT
You can parse through all the embedded content found in a PDF, which includes the text and the pictures, using the ParsePages method. This will give you access to the components of the PDF as objects. Here is some sample code which highlights this:
string pdfFileName = @"C:/Input/Leadtools.pdf"); using (PDFDocument document = new PDFDocument(pdfFileName)) { PDFParsePagesOptions options = PDFParsePagesOptions.All; document.ParsePages(options, 1, -1); foreach (PDFDocumentPage page in document.Pages) { foreach (PDFObject obj in page.Objects) { if (obj.ObjectType == PDFObjectType.Text) { Console.WriteLine(obj.code); // print found text } if (obj.ObjectType == PDFObjectType.Image) { //do work on image } } } }https://www.leadtools.com/help/sdk/dh/pdf/pdfobject.html