Hi
I am using Musltiple data and Musltile model view bags and disply to html this html page Data I Want to Convert PDF and Store in Db when submit button click
Hi
I am using Musltiple data and Musltile model view bags and disply to html this html page Data I Want to Convert PDF and Store in Db when submit button click
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajkiran SwainPosted May 30, 2023, 8:55 AM
To convert an HTML page to a PDF and store it in a database when a submit button is clicked, you can follow these general steps:
1. Set up your HTML page: Create your HTML page that displays the data from multiple data sources and model view bags.
2. Handle the submit button click: Add a form to your HTML page with a submit button. Use JavaScript or a server-side framework (such as ASP.NET, PHP, or Node.js) to handle the submit button click event.
3. Convert HTML to PDF: In the event handler for the submit button click, you need to convert the HTML page to a PDF. There are several libraries and tools available for this purpose, such as iTextSharp, wkhtmltopdf, Puppeteer, or Rotativa. Choose a library that is compatible with your server-side framework and integrate it into your code.
4. Store the PDF in the database: Once the HTML page is converted to a PDF, you can store the PDF file in the database. Depending on your database system, you may need to create a table with a column of the appropriate type (e.g., BLOB or VARBINARY) to store the PDF data. Use the appropriate database API or ORM (Object-Relational Mapping) framework to insert the PDF data into the database.
5. Handle any additional processing: If there are any additional steps or validations required before storing the PDF in the database, perform them in the submit button click event handler.
It's worth noting that storing PDF files directly in a database can have performance implications, and it may be more common to store the PDF file on a file system and save the file path or reference in the database instead. Consider your specific requirements and the capabilities of your database system when deciding how to handle the PDF storage.