Simple - except for the details, and the devil is always in the details :)
First off, I'm guessing you don't actually want to:
> rename with the parent folder's name
Because you would end up with a file in the subdirectory called 'Folder name A1', whereas I suspect you really want it to be called 'Folder Name A1.pdf'. Yes, it's a detail. but it's kind of important.
Second is whether the folders are always three deep. Are there files in the intermediate folders that you need to process (or ignore?).
What about if there are multiple .pdfs in the third folder. They can't both be renamed to the top folder name. What should the script do then? Copy the first? add numbers to the subsequent files? ask the user? Again, another detail, but it's important to address.
Answering these (and, potentially, other gotchas I can't even think about yet) are prerequisites to getting a working script.