title: PDF Generation in ASP.NET MVC with TCPDF
body: <p>Basically I'm after advice on producing dynamic PDFs with charts, images and some styling into a view or partial view for the user to print or optionally download.</p>
  
  <p>I've used TCPDF in the past, and so was wondering if there was any way to utilize my TCPDF php files to pass a generated PDF into a view?</p>
  
  <p>I've also looked at ITextSharp, but I was worried about the lack of customization including dynamic charts that TCPDF has provided me in the past.</p>
  
  <p>Could anyone point me in the right direction?  Currently I'm attempting to install VS.PHP module for Visual Studio 2010, in the hope I can load the generated TCPDF file into a memorystream and pass it to a view (inline).</p>
  
  <p>Is my logic totally wrong?  Please advise.</p>
  
  <p>Thanks.</p>
  
  <p>[EDIT]</p>
  
  <p>I've added Phalanger (http://phalanger.codeplex.com/) to my project along with some tcpdf examples in my Content/reports folder.</p>
  
  <p>my controller code was pretty simple (I got most of it from another post on the Phalanger forums):</p>
  
  <pre><code>        public ActionResult SummaryReport()
      {
          var context = PHP.Core.ScriptContext.CurrentContext;
  
          using (var request_context = PHP.Core.RequestContext.Initialize(PHP.Core.ApplicationContext.Default, System.Web.HttpContext.Current))
          {
              var output = request_context.ScriptContext.Include(Server.MapPath(Url.Content("~/Content/reports/testoutput.php")), false);
  
              return Content("");
          }
       }
  </code></pre>
  
  <p>However I'm now receiving TCPDF Errors when the controller tries to execute the TCPDF example:</p>
  
  <pre><code>Warning: preg_match(): Invalid argument 'pattern':     u0192\u2039\u008D\u203A\u017E\u0178\u00A1-\u00BA] # AL | Ù[\u20AC-\u0160\u00AD-\u00AF\u00B1-\u00BF] # AL | Ú[\u20AC-\u00BF] # AL | Û[\u20AC-\u2022\u009D\u00A5\u00A6\u00AE\u00AF\u00BA-\u00BF] # AL | Ü[\u20AC-\u008D\u0090\u2019-\u00AF] # AL | Ý[\u008D-\u00AD] # AL | Þ[\u20AC-\u00A5\u00B1] # AL | ï­[\u0090-\u00BF] # AL | ï®[\u20AC-\u00B1] # AL | ï¯[\u201C-\u00BF] # AL | ï[\u00B0-\u00B3][\u20AC-\u00BF] # AL | ï´[\u20AC-\u00BD] # AL | ïµ[\u0090-\u00BF] # AL | ï¶[\u20AC-\u008F\u2019-\u00BF] # AL | ï·[\u20AC-\u2021\u00B0-\u00BC] # AL | ï¹[\u00B0-\u00B4\u00B6-\u00BF] # AL | ïº[\u20AC-\u00BF] # AL | ï»[\u20AC-\u00BC] ..." - [x-y] range in reverse order. in (MYPATH)\Content\reports\tcpdf\tcpdf.php on line 15859, column 7.
  
  Warning: preg_match(): Invalid argument 'pattern': [x-y] range in reverse order. in (MYPATH)\Content\reports\tcpdf\tcpdf.php on line 15865, column 7.
  </code></pre>
  
  <p>Has anyone any idea how to overcome this?  I've taken the latest TCPDF at will most likely post on the TCPDF forum.  I fear if I can't get these working I will result to using a .NET PDF library as I'm under strict time constraints.</p>
  
  <p>Thanks for your time.</p>