![]() StringWriter stringWriter = new StringWriter() The string writer where to render the HTML code of the view ViewDataDictionary viewData = new ViewDataDictionary(model) Public ActionResult ConvertCurrentPageToPdf(FormCollection collection) net to perform the HTML to PDF conversion: The C# code below can be used in a MVC application to convert the current view to PDF and produce a PDF in a buffer that can be saved on server or sent to browser for download. VB.NET MVC version of the code can be found here: PdfDocument doc = converter.ConvertUrl(url) įileResult fileResult = new FileContentResult(pdf, "application/pdf") įileResult.FileDownloadName = "Document.pdf" create a new pdf document converting an url instantiate a html to pdf converter objectĬ = pageSize Ĭ = pdfOrientation Ĭ = webPageWidth Ĭ = webPageHeight Typeof(PdfPageOrientation), pdf_orientation, true) PdfPageOrientation pdfOrientation = (PdfPageOrientation)Enum.Parse( PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), pdf_page_size, true) ![]() Public ActionResult Convert(FormCollection collection) You can use the Free Html To Pdf Converter from SelectPdf ( ). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |