1

I would like to generate a PDF file for my reporting module. Here is my code in the controller in generating the PDF file.

public ActionResult Reports_CARF(int carf_id= 0) 
{
    var data = db.Dept_Approval_Data_vw.Where(x => x.carf_id == carf_id && x.request_category == "PETC Local Applications" && x.verified_by != null).ToList();

    return new PdfActionResult(data);
}

I have include this following in my controller:

using MvcRazorToPdf;
using iTextSharp.text;
using iTextSharp.text.pdf;

Now, when I try to run this code, I got this error displayed in the browser. enter image description here

Please advice. Thanks in advance.

Jen143Me
  • 273
  • 7
  • 24
  • Your use of `using` structures and explicit `close` calls most likely is wrong as the exception is an `ObjectDisposedException`, most probably in your `PdfActionResult` implementation. – mkl Oct 28 '15 at 05:17
  • Any solution to this issue? I am also struggling with same? – Sebastian Jan 30 '16 at 05:26
  • PDFHelpers\MvcRazorToPdf.cs:47 Reason for error Causing this error and cod is on this pastebin http://pastebin.com/JqJ4hfpW @mki can any one help ?? – Sebastian Jan 30 '16 at 05:39

1 Answers1

0

Based on personal experience, this is likely to be badly formed XHTML coming from your view causing an unhandled exception in MvcRazorToPdf.

Try rendering the view, e.g. return View() instead of return new PdfActionResult(data), and running the output through an XHTML validator.

MattyB
  • 1