I need to store a pdf (each pdf will be < 5 pages maximum) in a mySQL database (yes I know this is not recommended). The column is defined as mediumblob. The test pdf is 198 KB. I get the error "Errors occurred in addMedicalPlan: java.io.FileNotFoundException: " followed by a dump of the file " JVBERi0xLjcKCjQgMCBvYmoKKElkZW50aXR5KQplbmRvYmoKNS ......" and at the end "(The filename or extension is too long)".
I have managed to do this with images and have been trying to re-purpose that code to store the pdf; by researching articles and other questions. Unfortunately, for me, most of the example relate to PHP. I have been able to read the pdf and display it in the page with this code:
Do I need to strip off "data:application\/(pdf);base64", i.e., img2 = (img1.getAttribute('src')).replace(/^data:application\/(pdf);base64,/, ""); for the pdf? I do similar for storing my images (i.e., img2 = (img1.getAttribute('src')).replace(/^data:image\/(png|jpg|jpeg|gif);base64,/, "");). Is this superfluous for pdf files?
Take a look in to pdfBox.
I never used it to save a pdf to db, not sure if you're will be able to, I did use it before to convert a pdf in to a buffered image to show it in a javaFx Imageview, which you would be able to safe
It's good to be able to use someting, it's better to understand how it works.