I would say that as soon as you make a first function in your project, you need a unit tests for it, period. If your codebase consists purely of side-effect code, like the shell script, for example, you can do other types of automated tests, but if it's not some throwaway code like Esko Luontola described, you better write any automated tests than end up with none.
However, in some areas of the complete application there's no automated tools to do the check for you. GUI and everything that renders on screen is one example, as even Selenium don't have the interface to automatically check whether the modal window appearing animation really does play and is not glitchy. You must use a real person to manually test this stuff, and it's the reality of proper QA.
You PDF example is flawed in the sense that there's no notion of what feature set do you want to test in the PDF generator. If you need to be sure that the already checked data will be present in the resulting PDF, you can even do something absolutely blunt like grep through the file searching for that data, because PDF is nothing more than a text file with binary blobs for images in it, which you can safely skip in this case. If you need to be sure that the formatting is right, then currently there's no way to automate it, so you test it manually.
In the CRUD example, you do not stub the 3rd party ORM tool. You write a wrapper around it, because in next 2 years ORM tool either will be replaced by something more sparkly or just receive some BC-incompatible update. You then write the fullstack integration tests specifically for this wrapper, to be sure it does what your application needs, and then mock the wrapper in all other tests to prevent them to be dependent on the runtime environment. Both of these types of tests are crucial in preventing regressions and supporting you in refactoring.
In conclusion, I should note that if you care about your resulting application at all, you will test the validity of the functionality anyway. Point is, to test the application manually each time is a nightmare leading to almost no testing at all. So you need the automated tests. And to get the best feedback you want these automated tests run as often as possible, ideally constantly. For it, you need them to be crazy fast. And for automated test case to be crazy fast, there is no solution better than to test only the stuff relevant to this case. So, we ended with the the unit test definition, and did it naturally.