Page 1 of 1

Searching Inside PDF for Unique Number

Posted: Sun Sep 30, 2012 7:40 pm
by Yeller
I'd like to search new searchable PDF's that lands in a folder (filename is not known before arrival), and if a specific (unique) number is found in the PDF, move PDF to another folder.I'm using File Loop to identify the file name and Text Loop to store the string, but I continue to get a "Cannot open file" error.  Any suggestions?  Can RoboTask open PDF's?;*****************************;* RoboTask Task file;* Do not edit in text editor!;***************************** [Root]ActionAfterRun=INTEGER|0Actions=FOLDERAutomat=INTEGER|0CatID=INTEGER|0Comment=STRINGLISTContinueOnError=INTEGER|0Events=FOLDERExternalName=STRING|"Task3"Hide=INTEGER|0ID=INTEGER|957339960LogOnAsUser=INTEGER|1Name=STRING|"Wells Fargo"OnErrorTaskID=INTEGER|0Priority=INTEGER|3RunOnClose=INTEGER|0RunOnStartup=INTEGER|0ToLog=INTEGER|3WriteGeneralLog=INTEGER|0[Actions]Action1=FOLDERAction10=FOLDERAction2=FOLDERAction3=FOLDERAction4=FOLDERAction5=FOLDERAction6=FOLDERAction7=FOLDERAction8=FOLDERAction9=FOLDER[Actions\Action1]ActionID=STRING|"A_LOOP_FILE"Enabled=INTEGER|-1Name=STRING|"File Loop"Params=FOLDER[Actions\Action1\Params]createmode=STRING|"1"date1=STRING|"20120930"date2=STRING|"20120930"destvar=STRING|"WF_F_NAME"DuringDays=STRING|"1"DuringHours=STRING|"1"DuringMinutes=STRING|"1"DuringMonths=STRING|"1"file0=STRING|"D:\Shared\New\*.pdf"filecount=STRING|"1"OlderDays=STRING|"1"OlderHours=STRING|"1"OlderMinutes=STRING|"1"OlderMonths=STRING|"1"savesize=STRING|"0"searchkind=STRING|"0"subdirs=STRING|"1"timesize=STRING|"0"WithoutPath=STRING|"1"[Actions\Action10]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"[Actions\Action2]ActionID=STRING|"A_LOOP_TEXT"Enabled=INTEGER|-1Name=STRING|"Text Loop"Params=FOLDER[Actions\Action2\Params]destvar=STRING|"WF_LOAN"file=STRING|"{WF_F_NAME}"line0=STRING|"00000001"linecount=STRING|"1"sourcetext=STRING|"0"[Actions\Action3]ActionID=STRING|"A_LOOP_TEXT"Enabled=INTEGER|-1Name=STRING|"Text Loop"Params=FOLDER[Actions\Action3\Params]destvar=STRING|"WF_STRING"file=STRING|"{WF_LOAN}"linecount=STRING|"0"sourcetext=STRING|"0"[Actions\Action4]ActionID=STRING|"A_FLOW_IF"Enabled=INTEGER|-1Name=STRING|"If Then"Params=FOLDER[Actions\Action4\Params]case=STRING|"0"operator=STRING|"2"type=STRING|"0"value1=STRING|"00000001"value2=STRING|"{WF_STRING}"[Actions\Action5]ActionID=STRING|"A_FILE_COPY"Enabled=INTEGER|-1Name=STRING|"Copy/Move File"Params=FOLDER[Actions\Action5\Params]destdir=STRING|"D:\Shared\Wells Fargo"f_count=STRING|"1"file0=STRING|"D:\Shared\New\{WF_F_NAME}"hidden=STRING|"1"ifexists=STRING|"1"move=STRING|"1"subdir=STRING|"1"system=STRING|"1"[Actions\Action6]ActionID=STRING|"A_TASKS_STOP"Enabled=INTEGER|-1Name=STRING|"Stop Task ""Wells Fargo"""Params=FOLDER[Actions\Action6\Params]taskid=STRING|"957339960"[Actions\Action7]ActionID=STRING|"A_FLOW_ENDIF"Enabled=INTEGER|-1Name=STRING|"End If"[Actions\Action8]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"[Actions\Action9]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"[Events]Event1=FOLDER[Events\Event1]Enabled=INTEGER|-1EventID=STRING|"E_FILE_MONITOR"Params=FOLDERUnigueID=INTEGER|1375060653[Events\Event1\Params]chg=STRING|"0"chga=STRING|"1"chgsl=STRING|"1"chgsm=STRING|"1"chgtl=STRING|"1"chgtm=STRING|"1"del=STRING|"0"folder1=STRING|"D:\Shared\New"foldercount=STRING|"1"id=STRING|"9HMYXD7R4"incmask=STRING|"*.pdf"interval=STRING|"60"listmode=STRING|"1"mon_files=STRING|"1"mon_folders=STRING|"1"new=STRING|"1"saveresults=STRING|"0"subfolders1=STRING|"0"

Searching Inside PDF for Unique Number

Posted: Mon Oct 01, 2012 6:11 am
by Oleg
Text loop is for standard text only. Unfortunately RoboTask can't process PDF files directly.
But there are a couple workarounds:
1. You can open PDF in Acrobat reader, select all text and copy it to clipboard.
2. Acrobat reader allows to save your PDF as text (if it is possible)

Pay attention that pauses are required, because operations may take some time. You should adjust the value of pause yourself.

See examples below:

1-s example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task70"
Hide=INTEGER|0
ID=INTEGER|556619077
LocalVariables=STRING|"txt"
LogOnAsUser=INTEGER|1
Name=STRING|"try PDF"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""robotask.pdf """
Params=FOLDER

[Actions\Action1\Params]
ifnonzero=STRING|"0"
program=STRING|"c:\temp\robotask.pdf"
runas=STRING|"0"
wait=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 3000 ms"
Params=FOLDER

[Actions\Action2\Params]
delay=STRING|"30"

[Actions\Action3]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER

[Actions\Action3\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"1"
keylayout=STRING|"0"
keys=STRING|"^(A)^(C)"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 10000 ms"
Params=FOLDER

[Actions\Action4\Params]
delay=STRING|"100"

[Actions\Action5]
ActionID=STRING|"A_CLIPBOARD_GET"
Enabled=INTEGER|-1
Name=STRING|"Get Text"
Params=FOLDER

[Actions\Action5\Params]
variable=STRING|"txt"

[Actions\Action6]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file c:\temp\pdftext.txt"
Params=FOLDER

[Actions\Action6\Params]
fileexists=STRING|"0"
filname=STRING|"c:\temp\pdftext.txt"
line0=STRING|"{txt}"
linecount=STRING|"1"
suppress=STRING|"0"

[Actions\Action7]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""pdftext.txt """
Params=FOLDER

[Actions\Action7\Params]
ifnonzero=STRING|"0"
program=STRING|"c:\temp\pdftext.txt"
runas=STRING|"0"
wait=STRING|"0"
2-nd example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task74"
Hide=INTEGER|0
ID=INTEGER|55000138
LocalVariables=STRING|"txt"
LogOnAsUser=INTEGER|1
Name=STRING|"try PDF (2)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""robotask.pdf """
Params=FOLDER

[Actions\Action1\Params]
ifnonzero=STRING|"0"
program=STRING|"c:\temp\robotask.pdf"
runas=STRING|"0"
wait=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 3000 ms"
Params=FOLDER

[Actions\Action2\Params]
delay=STRING|"30"

[Actions\Action3]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER

[Actions\Action3\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"1"
keylayout=STRING|"0"
keys=STRING|"%(F)AX{enter}"
pause=STRING|"300"
release=STRING|"1"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 60000 ms"
Params=FOLDER

[Actions\Action4\Params]
delay=STRING|"600"

[Actions\Action5]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""robotask.txt """
Params=FOLDER

[Actions\Action5\Params]
ifnonzero=STRING|"0"
program=STRING|"c:\temp\robotask.txt"
runas=STRING|"0"
wait=STRING|"0"

Searching Inside PDF for Unique Number

Posted: Tue Oct 02, 2012 12:59 am
by Yeller
Thank you for taking the time to respond.  I'll try both and let you know the results. I've typically stayed away from Adobe Reader due to it's bloated size, but this is worth it.-----edit---The commands you've provided aren't specific to Adobe, meaning I can use my reader of choice (Foxit), thank you again.



Searching Inside PDF for Unique Number

Posted: Tue Oct 02, 2012 4:45 am
by Oleg
Of course you can use another reader, if it allows similar functions. This is not principled.

Searching Inside PDF for Unique Number

Posted: Sun Oct 07, 2012 12:26 am
by Yeller
I was able to modify the sample code you provided, adding if/then statements for the different destination folders (depending on the unique values) and it works like a charm.  Thanks again for your your help.