In the application that i use on my job, we need to set a maximum pdf size that the user can insert in the application.
Are you serializing the PDF and sending it in a JSON request?
If that is the case you could ask for the blob size during the serialization. However I would strongly recommend against this approach.
If you use a regular HTML form you could set the maxSize attribute