This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Pass html to ActionMethod

anonymous wrote on 2014-04-15:
I want to send my html view to ActionMethod in Controller as parameter(ex. as String) and that view to convert to pdf,please help me Im using mvc.net
support wrote on 2014-04-16:
Hello,

If you need to convert an HTML string to PDF, you can use the following code which saves the result to MyDocument.pdf in the current working directory.
pdfcrowd.Client client = new pdfcrowd.Client("***", "***");

fileStream = new FileStream("MyDocument.pdf", FileMode.CreateNew);
client.convertHtml(htmlString, fileStream);
fileStream.Close();
anonymous wrote on 2014-04-16:
is there any another way to pass html as string to controller I don't want to create file because some reasons,i pass html to controller but it's showing encoded symbols in page like in photo
support wrote on 2014-04-18:
Hello,

You can use any System.IO.Stream based class instead of FileStream. If you want to write the generated PDF to System.Web.HttpResponse, please go to https://pdfcrowd.com/api/html-to-pdf-dotnet/ and scroll down to the example in the "HTML to PDF in ASP.NET - C#" section.