using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.IO; using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace test { public partial class Form1 : Form { string filename; string path; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.CheckFileExists = true; openFileDialog.AddExtension = true; openFileDialog.Filter = "PDF files (*.pdf)|*.pdf"; DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) { //data1 = openFileDialog.FileNames.Select(x => new FileInfo(x)).ToArray(); filename = Path.GetFileName(openFileDialog.FileName); path = Path.GetDirectoryName(openFileDialog.FileName); textBox1.Text = path + "\\" + filename; } } public static string ExtractTextFromPdf(string filename) { using (PdfReader r = new PdfReader(filename)) { StringBuilder text = new StringBuilder(); for (int i = 1; i <= r.NumberOfPages; i++) { text.Append(PdfTextExtractor.GetTextFromPage(r, i)); } string first = text.ToString(); return first; } } private void button3_Click(object sender, EventArgs e) { string s= Form1.ExtractTextFromPdf(textBox1.Text); } } }
string reverseValue = new string(s.Select((c, index) => new { c, index }) .OrderByDescending(x => x.index) .Select(x => x.c) .ToArray());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)