By default, the IIS web server processes requests for static content like images and HTML files without invoking the ASP.NET engine. Consequently, if the user requests a non-existent file they will get back IIS's default 404 error message rather than ASP.NET's configured error page.
A PDF download request would be taken care of by IIS and not ASP.Net handlers.
As a result, you don't see your 404 custom error handler page.
Have a look at
http://www.asp.net/web-forms/tutorials/deployment/displaying-a-custom-error-page-cs[
^] for more details.