Can I extract and rename an embedded attachment from a pdf?

Hi, I'm trying to take an input file which is a PDF with an embedded attachment and do 2 actions:-
1. Rename the file based on a reference within the text of the file
2. Take the embedded attachment and rename that based on the same reference and save that on it's own in a separate folder.
I can do action 1 OK, but I'm stumped when it comes to action 2. Is this possible within Hazel, or will I need to learn some AppleScript to do this?
Many thanks for any ideas/suggestions.
Cheers,
Mike
1. Rename the file based on a reference within the text of the file
2. Take the embedded attachment and rename that based on the same reference and save that on it's own in a separate folder.
I can do action 1 OK, but I'm stumped when it comes to action 2. Is this possible within Hazel, or will I need to learn some AppleScript to do this?
Many thanks for any ideas/suggestions.
Cheers,
Mike