asp.net web api - Getting exception while using itextsharp to convert from html to pdf in web api -
list item I'm getting Exception After the method of my Web API controller that gets the HTML data and convert it to PDF. [System.Web.Http.AcceptVerbs ("GET", "Post")] Public HttpResponseMessage DownloadPDF (long estimationId) {HttpResponseMessage results = New HTTPPassSpaceMessage (HTTPPttatus code.OK); Try to get the data for method calculation and convert it to HTML string html = objRepository.GetHTML (Estimate ID); // Create PDF var document = new iTextSharp.text.Document (PageSize.A4); Document.SetMargins (20.0 f, 20.0 f, document TopMargin + 20, document. Botomargin); Var output = new memorystream (); Var Author = PdfWriter.GetInstance (Document, Output); Document.Open (); StringRedder Strat = New StringRadder (HTML); Var parseedHtmlElements = HTMLWorker.ParseToList (strRdr, null); Foreach (html) element in crossed HTML analytics document.Add (HTMLElement as IElement); Author. Close stream = false; Writer.flush (); // document.Close (); Output. Search (0, SeekOrigin.Begin); Result. Resource = New Byterendant (Output OORA); } Hold (exception e) {ErrorLog.GetDefault (System.Web.HttpContext.Current). Logs (new error (e)); } Return results; } exception Any help please Inspecting your HTML Exception is actually an iTextSharp exception, but instead comes from iTextSharp. Net Framework is asking to download a remote resource via the A first instance of type 'System.NotSupportedException' occurred in system.dll exception type 'System.NotSupportedException' of an unspecified exception system Additional information: URI prefix is not recognized If you had a protocol short / protocol relative URL you would receive a slightly different message. / P> A first instance of System.Net.WebException exception system.dll occurred in the exception of an unspecified type of 'System.Net .WebException 'happened in System.dll' Additional information: The form of UNC path should be \ server \ share. You have to change the HTML only to use a support protocol or potentially. "uri prefix is not recognized iTextSharp"
on parsedHtmlElements = HTMLWorker.ParseToList (strRdr, tap) on line;
System.Net.WebRequest . In a way or another, you have got the URL that is
http or
https (or
file or
ftp ), often This is a base 64 encoded image. You can reproduce this message by doing this:
var req = System.Net.WebRequest.Create ("data: image / png; base64"); Req.GetResponse ();
var req = System.Net.WebRequest.Create ("// gerp"); Req.GetResponse ();
Comments
Post a Comment