1-) C# RMOS - pdf to text pdf den stringe çevirme pdf reader
kaynak :
https://stackoverflow.com/questions/83152/reading-pdf-documents-in-net
1-) C# RMOS - iTextSharp -> Manage NuGet den indir
2-) Kod
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
namespace WindowsFormsApplication1
{
public static class PDFParser
{
public static string pdfText(string path)
{
PdfReader reader = new PdfReader(path);
string text = string.Empty;
for (int page = 1; page <= reader.NumberOfPages; page++)
{
text += PdfTextExtractor.GetTextFromPage(reader, page);
}
reader.Close();
return text; } }}
3-) Kullanımı
string path = @"C:\Users\Ramazan\Desktop\rar2.pdf";
string deger = PDFParser.pdfText(path);
var result = Path.ChangeExtension(path, ".txt"); // dosya uzantısı değiştirme
File.WriteAllText(result, deger);// .txt olarak yeni değeri kayıt eder
2-) DEVEXPRESS İLE AŞAĞIDAKİ .DLL LERİ EKLE
c:\Program Files (x86)\DevExpress 18.1\Components\Bin\Framework\DevExpress.Docs.v18.1.dll
C:\Program Files (x86)\DevExpress 18.1\Components\Bin\Framework\DevExpress.Pdf.v18.1.Core.dll
veya
c:\Program Files (x86)\DevExpress 15.1\Components\Bin\Framework\DevExpress.Docs.v15.1.dll
C:\Program Files (x86)\DevExpress 15.1\Components\Bin\Framework\DevExpress.Pdf.v15.1.Core.dll
2.1-) C# RMOS - kod
using DevExpress.Pdf;
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string path = @"C:\Users\Ramazan\Desktop\rar2.pdf";
string deger = ExtractTextFromPDF(path);
}
public string ExtractTextFromPDF(string filePath)
{
string documentText = "";
try
{
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor())
{
documentProcessor.LoadDocument(filePath);
documentText = documentProcessor.Text;
}
}
catch { }
return documentText; }
}}