cancel
Showing results for 
Search instead for 
Did you mean: 

ITEXT SHARP CODE- EXTRACT PDF

HIMADRIKHETO
Level 2
try {
PdfReader reader = new PdfReader(source_file);
PdfReaderContentParser parser = new PdfReaderContentParser(reader);
FileStream fs = new FileStream(destination_file_path+"//"+destination_file_name+".txt",FileMode.Create);
StreamWriter sw=new StreamWriter(fs);
SimpleTextExtractionStrategy strategy;
for (int i = 1; i <= reader.NumberOfPages; i++) {
strategy = parser.ProcessContent(i, new SimpleTextExtractionStrategy());
var s = strategy.GetResultantText();

sw.WriteLine(strategy.GetResultantText());

}

sw.Flush();
sw.Close();
Contents = File.ReadAllText(destination_file_path+"//"+destination_file_name+".txt");
Success = true;
Message ="No Error";
}
catch ( Exception caughtEx )
{
Message = caughtEx.Message;
Contents = "";
Success = false;

------------------------------
HIMADRI KHETO
------------------------------
2 REPLIES 2

TracySchultz
Level 6
You might want to ensure you're also checking for password protected files. I've been working on building a group of items that works using the latest itextsharp dll.

------------------------------
Tracy Schultz
Weaver LLC
TX
------------------------------

TahaSonmez
Level 5
Hi Himadri,

Our free VBO uses iTextSharp.dll to handle basic PDF actions. You can download from DigitalExchange to use directly or investigate the code.

Happy automation!

------------------------------
Taha Sonmez
ROM Architect
SabanciDx
------------------------------