Converting HTML to PDF and saving the pdf in backend
Hi,
i have a requirement in which i will be hitting a url(http://example.com/home/index?buID=123) where buID is the URL parameter. With respect to the url parameter buID some html are generated using jquery.
I want to convert the generated html(or entire webpage) after hitting the above url to pdf.
Can anyone let me know is these the optimal solution for the above?
1) getting entire html in a variable using jquery and passing it as a parameter to servlet where logic for converting html to pdf is written(ajax call) as shown
var text = $('#mycontent').html().toString();
var doc = new DOMParser().parseFromString(text, 'text/html');
var result = new XMLSerializer().serializeToString(doc);
console.log(result);
$.ajax({
type: 'GET',
url: '/bin/example/pdfGenerationServlet',
data: {'text': result},
success: function(msg){
console.log(msg);
},
error:function(text){});
