I am trying to save html page to pdf using evopdf htmlToPdfConverter. The html page is using jquery ajax to get the data from web api. Any static html content in the html page is printed in the pdf but the tables showing the data from the api are not getting populated. The url in the code below opens correctly and loads the data from api when opened in browser.
Here is the code in the Console Application that I created that references the URL and should save the html page as pdf.
//console application
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter(); // cP7t/+rv/+zo6Oj/5/Hv/+zu8e7t8ebm5ub/7w== // HpCAkYKCkYKDiZGIn4GRgoCfgIOfiIiIiJGB
htmlToPdfConverter.LicenseKey = "HpCxxxxxxxxxxxxxxxxxxx";
htmlToPdfConverter.MediaType = "print";
htmlToPdfConverter.HtmlViewerWidth = 1024;
htmlToPdfConverter.PdfDocumentOptions.SinglePage = true; // SinglePagePdf.Checked;
htmlToPdfConverter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Landscape;
htmlToPdfConverter.JavaScriptEnabled = true;
htmlToPdfConverter.ConversionDelay = 15;
string url = "https://localhost:44354/trm/test.html?pid=231";
string fileName = @"C:\QSaves\test.pdf";
htmlToPdfConverter.ConvertUrlToFile(url, fileName);
/////////////////////////////////////////
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function () {
function main() {
$.ajax({
url: 'api/csheet/?ID=' + 10,
type: 'get',
dataType: 'json',
success: function (data) {
$('#CTable').removeClass('w3-hide');
var tbl = $("#CompanyTable").dataTable({
destroy: true,
searching: false,
fixedHeader: {
header: true,
footer: true
},
data: data.Items,
sScrollX: true,
scrollH: true,
sScrollXInner: '100%',
processing: true,
bPaginate: false,
dom: 'Bfrtip',
columns: [
{
'data': 'Name',
},
]
});
}
});
}
main();
});
</script>