Convert PDF to Text (Views: 30)
Problem/Question/Abstract: Convert PDF to Text Answer: If Reader is installed this code will do it for you: { courtesy DLoke on the Delphi-Talk mailing list http://www.elists.org } procedure Tform1.PDF2Text(APDFFileName, ATextFileName: TFileName); var App, AVDoc: Variant; begin //create an instance. if no running instance is found a new one is started App := CreateOleObject('AcroExch.App'); // App.Show; //only if you want to.. AVDoc := App.GetActiveDoc; //doc handle AVDoc.Open(APDFFileName, ''); //see note below //select all and copy to clipboard App.MenuItemExecute('Edit'); App.MenuItemExecute('SelectAll'); App.MenuItemExecute('Edit'); App.MenuItemExecute('Copy'); // Memo1 CAN be set to invisible // You need this in order to get it from // the clipboard into a text file Memo1.PasteFromClipboard; // Save the text to a file Memo1.Lines.SaveToFile(ATextFileName); App.Exit; //unless you want to leave it running. end; |