I have a lot of tables with lot of rows and columns which I am trying to export into a pdf
on a button click in an asp.net webform
. This data looks good in a listview
. I used iTextSharp
, but I couldn't figure out how to export listview
to pdf
using iTextSharp
. So I used datatable
and it didn't look very well with iTextSharp
. I came across "Spire.DataExport for .NET"
but it doesn't seem to be available freely.
Please let me know what's the best way to export a listview
into a pdf
in asp.net
.
UPDATE:
I tried using wkhtmltopdf from codaxy's github link. But even for a simple html line, the conversion is failing from the c# code. Any help on this will be really appreciated, as I have spent a lot of time on this getting nowhere.
c# code:
PdfConvert.ConvertHtmlToPdf(
new PdfDocument { Html = "<html><h1>test</h1></html>
" },
new PdfOutput { OutputFilePath = "inline.pdf" }
);
Error::
Server Error in '/JobCosting' Application.
Html to PDF conversion of '-' failed. Wkhtmltopdf output:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: PdfConvertException: Html to PDF conversion of '-' failed. Wkhtmltopdf output:
Source Error:
Line 292: if (process.ExitCode != 0 && !File.Exists(outputPdfFilePath)) Line 293: { Line 294: throw new PdfConvertException(String.Format("Html to PDF conversion of '{0}' failed. Wkhtmltopdf output: \r\n{1}", document.Url, error)); Line 295: } Line 296: }