Author: Lou Adler
Convert PDF to Text
Answer:
If Reader is installed this code will do it for you:
1 {2 courtesy DLoke on the Delphi-Talk mailing list3 http://www.elists.org4 }5 6 procedure Tform1.PDF2Text(APDFFileName, ATextFileName: TFileName);
7 var8 App, AVDoc: Variant;
9 begin10 //create an instance. if no running instance is found a new one is started11 App := CreateOleObject('AcroExch.App');
12 // App.Show; //only if you want to..13 AVDoc := App.GetActiveDoc; //doc handle14 AVDoc.Open(APDFFileName, ''); //see note below15 //select all and copy to clipboard16 App.MenuItemExecute('Edit');
17 App.MenuItemExecute('SelectAll');
18 App.MenuItemExecute('Edit');
19 App.MenuItemExecute('Copy');
20 // Memo1 CAN be set to invisible21 // You need this in order to get it from22 // the clipboard into a text file23 Memo1.PasteFromClipboard;
24 // Save the text to a file25 Memo1.Lines.SaveToFile(ATextFileName);
26 App.Exit; //unless you want to leave it running.27 end;