Struggling to convert HTML & CSS into a downloadable PDF page using Django and Weasyprint. The current tutorial isn't working as expected - I need the PDF to render the current page when the user clicks on the download button, automatically downloading with read-only privileges. This entire process is turning out to be more challenging than anticipated.
Weasyprint only converts a URL in Django to a PDF file, but I can't figure out how to link the download button to the Weasyprint view.
I might be overcomplicating things - any help would be greatly appreciated.
Here's an example of Weasyprint code:
(code snippet)
I set up a virtual environment on my PC exactly like the example provided, currently utilizing Bootstrap 4.
If there's a better way to achieve this, please share your insights :)
Moreover, I'm looking to target only the body tags for conversion to PDF, not the entire webpage.
Previously, I tried using this solution: https://codepen.io/AshikNesin/pen/KzgeYX, but it didn't work effectively.
*EDIT 2.0*
Switching to JavaScript now, I'm struggling with a script that doesn't create a PDF form upon clicking. Is there a way to ensure the JS function downloads only the selected ID within the div, without affecting resolution or scale? (To avoid rendering unnecessary content)
https://jsfiddle.net/u4ko9pzs/18/
Any suggestions or advice would be highly appreciated.