Ok guys, I have looked far and wide for something to do something like this, but with no luck.
I need to be able to extract certain texts out of PDFs.
I found a certain type of function that basically opens Adobe with the selected file (I will be doing batches at once, but I can easily set that up). It then reads the text in from Adobe into a RichEdit (used for searching for the text). My problem is that I am not sure this solution would work anymore, as for the latest 3 sets of contracts we have received now have permission restrictions on them for no good reason. We have been receiving them for years without them, and now they are restricted. The code that I was able to find does this to take the text from PDF and put it into a RichEdit:
var
App, AVDoc : Variant;
begin
App := CreateOleObject ('AcroRd32.Application');
AVDoc := App.GetActiveDoc;
AVDoc.Open (APDFFileName,'');
App.MenuItemExecute('Edit');
App.MenuItemExecute('SelectAll');
App.MenuItemExecute('Edit');
App.MenuItemExecute('Copy');
pdfer.PasteFromClipboard;
end;
I believe this will not work because it still uses Adobe to open the file, and would probably prevent the Copy command from working (I tested manually copying out of the PDF and it is restricted, as it says so in the Security settings).
So I suppose I kind of have 2 questions.
As is, that code is not working at all. I figured out the adding ComObj to the uses for Delphi to understand the CreateOLEObject part. But that line is still giving me an error. It says "Invalid Class String". I have tried changing the name of the application around to a few things, but so far have not fixed it (I think that is where the problem is?).
The second question is, does anyone have any small amount of code that can go through and remove permission restrictions on PDFs? This would solve my problem about not being able to copy from the PDFs that are our contracts anyways. Right now we can only open and print them (which is a huge waste of paper and time since we only need a small amount of info from them).
~
Give a man some fire, he will be warm for a day, Set a man on fire, he will be warm for the rest of his life.
I need to be able to extract certain texts out of PDFs.
I found a certain type of function that basically opens Adobe with the selected file (I will be doing batches at once, but I can easily set that up). It then reads the text in from Adobe into a RichEdit (used for searching for the text). My problem is that I am not sure this solution would work anymore, as for the latest 3 sets of contracts we have received now have permission restrictions on them for no good reason. We have been receiving them for years without them, and now they are restricted. The code that I was able to find does this to take the text from PDF and put it into a RichEdit:
var
App, AVDoc : Variant;
begin
App := CreateOleObject ('AcroRd32.Application');
AVDoc := App.GetActiveDoc;
AVDoc.Open (APDFFileName,'');
App.MenuItemExecute('Edit');
App.MenuItemExecute('SelectAll');
App.MenuItemExecute('Edit');
App.MenuItemExecute('Copy');
pdfer.PasteFromClipboard;
end;
I believe this will not work because it still uses Adobe to open the file, and would probably prevent the Copy command from working (I tested manually copying out of the PDF and it is restricted, as it says so in the Security settings).
So I suppose I kind of have 2 questions.
As is, that code is not working at all. I figured out the adding ComObj to the uses for Delphi to understand the CreateOLEObject part. But that line is still giving me an error. It says "Invalid Class String". I have tried changing the name of the application around to a few things, but so far have not fixed it (I think that is where the problem is?).
The second question is, does anyone have any small amount of code that can go through and remove permission restrictions on PDFs? This would solve my problem about not being able to copy from the PDFs that are our contracts anyways. Right now we can only open and print them (which is a huge waste of paper and time since we only need a small amount of info from them).
~
Give a man some fire, he will be warm for a day, Set a man on fire, he will be warm for the rest of his life.