ITEXT SHARP CODE- EXTRACT PDF
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-11-21 10:21 AM
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
------------------------------
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-11-21 03:00 PM
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
------------------------------
------------------------------
Tracy Schultz
Weaver LLC
TX
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-11-21 03:32 PM
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
------------------------------
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
------------------------------
