Wondering how I would go about creating a document control module. Currently the documents are in PDF format. I tried using the picture uploader, but it says PDFs aren't pictures.
My current implementation is a website that has a link to download the PDF and doesn't have any security. Would like to make a system where people have to login and then the PDF is displayed in a website instead of downloading to an employee's phone.
Not sure how I would go about doing this with Trongate. Any suggestions would be greatly appreciated!
Document Control module
4 years ago
4 years ago
#1
4 years ago
#2
I see a WordPress module that is using this JS library.
https://github.com/mozilla/pdf.js
How difficult would it be for a novice programmer to modify the image uploader to be a PDF uploader and viewer that uses PDF.js?
https://github.com/mozilla/pdf.js
How difficult would it be for a novice programmer to modify the image uploader to be a PDF uploader and viewer that uses PDF.js?
4 years ago
#3
Hi cisnez,
The picture_uploader was designed for pictures, it checks for width, height, creates thumbs and reduces the image size as per the picture settings
however there is also another function in Trongate.php called 'upload_file' you could use:
it has a slight issue in php8.1 where the php community decided to not support 'FILTER_SANITIZE_STRING' anymore, and I'll probably create a pull request soon to fix that - unless someone else beats me to it :)
You can change it for FILTER_UNSAFE_RAW or do a htmlspecialchar() on the destination string, depending on how paranoid you are about security and if you are using pre php8.1.
To call this function you will need to pass in a config array, with a minimum of
You can also do some validation on the $_FILES() object which looks like this
to check for file type and size, or you can create your own file uploader, the possibilities are endless.
As for using https://github.com/mozilla/pdf.js it would be easy to add to Trongate as an asset in your module, and would even make a good module to upload to the Module Market.
Cheers,
Simon
The picture_uploader was designed for pictures, it checks for width, height, creates thumbs and reduces the image size as per the picture settings
however there is also another function in Trongate.php called 'upload_file' you could use:
it has a slight issue in php8.1 where the php community decided to not support 'FILTER_SANITIZE_STRING' anymore, and I'll probably create a pull request soon to fix that - unless someone else beats me to it :)
You can change it for FILTER_UNSAFE_RAW or do a htmlspecialchar() on the destination string, depending on how paranoid you are about security and if you are using pre php8.1.
To call this function you will need to pass in a config array, with a minimum of
You can also do some validation on the $_FILES() object which looks like this
to check for file type and size, or you can create your own file uploader, the possibilities are endless.
As for using https://github.com/mozilla/pdf.js it would be easy to add to Trongate as an asset in your module, and would even make a good module to upload to the Module Market.
Cheers,
Simon
4 years ago
#4
Simon, thank you for the detailed response.
Someday I hope to understand it all. The github for PDF.js says to reskin their viewer.html if used. I can't even figure out how to do that. Looks like it will be a big learning project for me to use just their pdf.js in a Trongate module.
I tried to see if I could get their package working as-is by creating an assets folder in welcome and extracting their zip file there. It produces build, js, and web folders. Then I added a link to the html viewer, but it doesn't work. Not surprised since the .html doesn't follow the Trongate framework.
Marking this answered (I just learned about that) and will hope it's enough to get me through the dev process once I get that far.
Someday I hope to understand it all. The github for PDF.js says to reskin their viewer.html if used. I can't even figure out how to do that. Looks like it will be a big learning project for me to use just their pdf.js in a Trongate module.
I tried to see if I could get their package working as-is by creating an assets folder in welcome and extracting their zip file there. It produces build, js, and web folders. Then I added a link to the html viewer, but it doesn't work. Not surprised since the .html doesn't follow the Trongate framework.
Marking this answered (I just learned about that) and will hope it's enough to get me through the dev process once I get that far.