Error compiling template "/Designs/Dwsimple/Paragraph/FavoritelistPDFGenFeed.cshtml"
Line 94: 'HtmlToPdf' is obsolete: 'Please use ChromePdfRenderer'
Line 94: 'HtmlToPdf' is obsolete: 'Please use ChromePdfRenderer'
Line 98: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 98: 'PdfPrintOptions' is obsolete: 'Please use the newer API class IronPdf.ChromePdfRenderOptions'
Line 98: 'PdfPrintOptions.PdfPaperSize' is obsolete: 'Please use the newer API Enum IronPdf.Rendering.PdfCssMediaType'
Line 99: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 100: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 100: 'PdfPrintOptions' is obsolete: 'Please use the newer API class IronPdf.ChromePdfRenderOptions'
Line 100: 'PdfPrintOptions' does not contain a definition for 'PdfPaperOrientation'
Line 101: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 102: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 102: 'ChromePdfRenderOptions.FitToPaperWidth' is obsolete: 'Please use the newer API property IronPdf.ChromePdfRenderOptions.FitToPaperMode'
Line 103: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 103: 'ChromePdfRenderOptions.JpegQuality' is obsolete: 'JpegQuality is now automatically managed by the Chorme rendering engine based on any JPEG images referenced in your HTML.'
Line 104: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 105: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 106: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 107: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 108: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 109: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 110: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 110: 'PdfPrintOptions' is obsolete: 'Please use the newer API class IronPdf.ChromePdfRenderOptions'
Line 110: 'PdfPrintOptions.PdfCssMediaType' is obsolete: 'Please use the newer API Enum IronPdf.Rendering.PdfCssMediaType'
Line 111: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 112: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 112: Cannot implicitly convert type 'System.Uri' to 'string'
Line 117: 'HtmlHeaderFooter.Height' is obsolete
Line 118: 'HtmlToPdf.PrintOptions' is obsolete: 'Please use ChromePdfRenderer'
Line 118: 'ChromePdfRenderOptions' does not contain a definition for 'Footer' and no accessible extension method 'Footer' accepting a first argument of type 'ChromePdfRenderOptions' could be found (are you missing a using directive or an assembly reference?)
Line 128: 'HtmlHeaderFooter.Height' is obsolete
Line 126: 'PdfDocument' does not contain a definition for 'HtmlHeaderFooter' and no accessible extension method 'HtmlHeaderFooter' accepting a first argument of type 'PdfDocument' could be found (are you missing a using directive or an assembly reference?)

1 //------------------------------------------------------------------------------ 2 // <auto-generated> 3 // This code was generated by a tool. 4 // Runtime Version:4.0.30319.42000 5 // 6 // Changes to this file may cause incorrect behavior and will be lost if 7 // the code is regenerated. 8 // </auto-generated> 9 //------------------------------------------------------------------------------ 10 11 namespace CompiledRazorTemplates.Dynamic { 12 using System; 13 using System.Collections.Generic; 14 using System.Linq; 15 16 #line 2 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 17 using Dynamicweb.Admin; 18 19 #line default 20 #line hidden 21 22 #line 3 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 23 using Dynamicweb.Core; 24 25 #line default 26 #line hidden 27 28 #line 4 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 29 using Dynamicweb.Logging; 30 31 #line default 32 #line hidden 33 34 #line 5 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 35 using Dynamicweb.Rendering; 36 37 #line default 38 #line hidden 39 40 #line 6 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 41 using Dynamicweb.Security.UserManagement; 42 43 #line default 44 #line hidden 45 46 #line 7 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 47 using Hounisen.SingleSignOn.User; 48 49 #line default 50 #line hidden 51 52 #line 8 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 53 using IronPdf; 54 55 #line default 56 #line hidden 57 58 59 public class RazorEngine_17261ee62a444ef2930f6b3484ed0cb2 : Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> { 60 61 #line hidden 62 63 public RazorEngine_17261ee62a444ef2930f6b3484ed0cb2() { 64 } 65 66 public override void Execute() { 67 68 #line 9 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 69 70 string listId = Dynamicweb.Context.Current.Request.QueryString["listid"]; 71 string favoriteListHtml = ""; 72 string response = ""; 73 var logger = LogManager.Current.GetLogger("Hounisen/FavoriteListPDF"); 74 if (!string.IsNullOrEmpty(listId)) 75 { 76 //time the execution of the generation 77 var watch = System.Diagnostics.Stopwatch.StartNew(); 78 var result = Dynamicweb.Ecommerce.CustomerCenter.CustomerProductList.GetListById(Convert.ToInt32(listId)); 79 if (result == null) 80 { 81 logger.Log("Couldn't find the list. Supplied ID was: " + listId); 82 response = "not found"; 83 } 84 else 85 { 86 var user = User.GetUserByID(result.AccessUserId); 87 if (System.IO.File.Exists(SystemInformation.MapPath($"/Files/Files/PDF/{user.Name}-{listId}.pdf"))) 88 { 89 System.IO.File.Delete(SystemInformation.MapPath($"/Files/Files/PDF/{user.Name}-{listId}.pdf")); 90 } 91 92 93 94 HtmlToPdf Renderer = new HtmlToPdf(); 95 96 IronPdf.License.LicenseKey = "IRONPDF-165189841E-239324-41D935-82965749F2-82546687-UExC937DF458778BD8-IRO220718.1022.26116.LITE.1YR.SUPPORTED.UNTIL.18.JUL.2023"; 97 // Init document settings 98 Renderer.PrintOptions.PaperSize = PdfPrintOptions.PdfPaperSize.A4; 99 Renderer.PrintOptions.PrintHtmlBackgrounds = true; 100 Renderer.PrintOptions.PaperOrientation = PdfPrintOptions.PdfPaperOrientation.Portrait; 101 Renderer.PrintOptions.Title = "Hounisen favoritliste"; 102 Renderer.PrintOptions.FitToPaperWidth = true; 103 Renderer.PrintOptions.JpegQuality = 100; 104 Renderer.PrintOptions.Zoom = 100; 105 Renderer.PrintOptions.GrayScale = false; 106 Renderer.PrintOptions.MarginLeft = 10; 107 Renderer.PrintOptions.MarginRight = 10; 108 Renderer.PrintOptions.MarginBottom = 0; 109 Renderer.PrintOptions.MarginTop = 0; 110 Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen; 111 Renderer.PrintOptions.InputEncoding = System.Text.Encoding.UTF8; 112 Renderer.PrintOptions.CustomCssUrl = new Uri(SystemInformation.MapPath("/Files/Files/PDF/pdfstyle.css")); 113 114 //Document info (page info and more) 115 HtmlHeaderFooter footer = new HtmlHeaderFooter(); 116 footer.HtmlFragment = "<div class='footer-container'><p>" + result.Name + "</p><p>Side {page} af {total-pages}</p></div>"; 117 footer.Height = 20; 118 Renderer.PrintOptions.Footer = footer; 119 120 Template template = new Template("Designs/Dwsimple/Paragraph/FavoritelistPDFTemplate.cshtml"); 121 template.SetTag("MyListID", listId); 122 //get html 123 favoriteListHtml = template.Output(); 124 var PDF = Renderer.RenderHtmlAsPdf(favoriteListHtml); 125 //Center footer text 126 PDF.HtmlHeaderFooter(new HtmlHeaderFooter() 127 { 128 Height = 25, 129 HtmlFragment = "<div style='text-align: center;position:relative;'><div style='display:inline-block;margin-right:20px'><img width='50' height='50' src='https://hounisen.com/Files/Images/Website/Logo/hounisen-logo.png'/></div><div style='display:inline-block;'><span style='font-weight:bold;font-size:18px'>Hounisen laboratorieudstyr A/S</span><br><span style='color:#676767;line-height:20px;'>Tlf. +45 86 21 08 00 | salg@hounisen.com<span/><br><a style='color:#D20A11;text-decoration:none;' href='https://www.hounisen.com'>www.hounisen.com</a></div></div>" 130 }, 0, 0, 0); 131 PDF.SaveAs(SystemInformation.MapPath($"/Files/Files/PDF/{user.Name}-{listId}.pdf")); 132 response = $"/Files/Files/PDF/{user.Name}-{listId}.pdf"; 133 watch.Stop(); 134 logger.Log($"User ({user.ID}) generated a pdf of their favorite list ({listId}). [Path: {response}] [Execution took: {watch.ElapsedMilliseconds}ms]"); 135 } 136 } 137 else 138 { 139 logger.Log("No list ID supplied"); 140 response = "no {listid} supplied"; 141 } 142 143 144 #line default 145 #line hidden 146 WriteLiteral("\r\n"); 147 148 149 #line 83 "D:\web\hounisen\Hounisen.Website\Files\Templates\Designs\Dwsimple\Paragraph\FavoritelistPDFGenFeed.cshtml" 150 Write(response); 151 152 153 #line default 154 #line hidden 155 } 156 } 157 } 158

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Admin 3 @using Dynamicweb.Core 4 @using Dynamicweb.Logging 5 @using Dynamicweb.Rendering 6 @using Dynamicweb.Security.UserManagement 7 @using Hounisen.SingleSignOn.User 8 @using IronPdf 9 @{ 10 string listId = Dynamicweb.Context.Current.Request.QueryString["listid"]; 11 string favoriteListHtml = ""; 12 string response = ""; 13 var logger = LogManager.Current.GetLogger("Hounisen/FavoriteListPDF"); 14 if (!string.IsNullOrEmpty(listId)) 15 { 16 //time the execution of the generation 17 var watch = System.Diagnostics.Stopwatch.StartNew(); 18 var result = Dynamicweb.Ecommerce.CustomerCenter.CustomerProductList.GetListById(Convert.ToInt32(listId)); 19 if (result == null) 20 { 21 logger.Log("Couldn't find the list. Supplied ID was: " + listId); 22 response = "not found"; 23 } 24 else 25 { 26 var user = User.GetUserByID(result.AccessUserId); 27 if (System.IO.File.Exists(SystemInformation.MapPath($"/Files/Files/PDF/{user.Name}-{listId}.pdf"))) 28 { 29 System.IO.File.Delete(SystemInformation.MapPath($"/Files/Files/PDF/{user.Name}-{listId}.pdf")); 30 } 31 32 33 34 HtmlToPdf Renderer = new HtmlToPdf(); 35 36 IronPdf.License.LicenseKey = "IRONPDF-165189841E-239324-41D935-82965749F2-82546687-UExC937DF458778BD8-IRO220718.1022.26116.LITE.1YR.SUPPORTED.UNTIL.18.JUL.2023"; 37 // Init document settings 38 Renderer.PrintOptions.PaperSize = PdfPrintOptions.PdfPaperSize.A4; 39 Renderer.PrintOptions.PrintHtmlBackgrounds = true; 40 Renderer.PrintOptions.PaperOrientation = PdfPrintOptions.PdfPaperOrientation.Portrait; 41 Renderer.PrintOptions.Title = "Hounisen favoritliste"; 42 Renderer.PrintOptions.FitToPaperWidth = true; 43 Renderer.PrintOptions.JpegQuality = 100; 44 Renderer.PrintOptions.Zoom = 100; 45 Renderer.PrintOptions.GrayScale = false; 46 Renderer.PrintOptions.MarginLeft = 10; 47 Renderer.PrintOptions.MarginRight = 10; 48 Renderer.PrintOptions.MarginBottom = 0; 49 Renderer.PrintOptions.MarginTop = 0; 50 Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen; 51 Renderer.PrintOptions.InputEncoding = System.Text.Encoding.UTF8; 52 Renderer.PrintOptions.CustomCssUrl = new Uri(SystemInformation.MapPath("/Files/Files/PDF/pdfstyle.css")); 53 54 //Document info (page info and more) 55 HtmlHeaderFooter footer = new HtmlHeaderFooter(); 56 footer.HtmlFragment = "<div class='footer-container'><p>" + result.Name + "</p><p>Side {page} af {total-pages}</p></div>"; 57 footer.Height = 20; 58 Renderer.PrintOptions.Footer = footer; 59 60 Template template = new Template("Designs/Dwsimple/Paragraph/FavoritelistPDFTemplate.cshtml"); 61 template.SetTag("MyListID", listId); 62 //get html 63 favoriteListHtml = template.Output(); 64 var PDF = Renderer.RenderHtmlAsPdf(favoriteListHtml); 65 //Center footer text 66 PDF.HtmlHeaderFooter(new HtmlHeaderFooter() 67 { 68 Height = 25, 69 HtmlFragment = "<div style='text-align: center;position:relative;'><div style='display:inline-block;margin-right:20px'><img width='50' height='50' src='https://hounisen.com/Files/Images/Website/Logo/hounisen-logo.png'/></div><div style='display:inline-block;'><span style='font-weight:bold;font-size:18px'>Hounisen laboratorieudstyr A/S</span><br><span style='color:#676767;line-height:20px;'>Tlf. +45 86 21 08 00 | salg@hounisen.com<span/><br><a style='color:#D20A11;text-decoration:none;' href='https://www.hounisen.com'>www.hounisen.com</a></div></div>" 70 }, 0, 0, 0); 71 PDF.SaveAs(SystemInformation.MapPath($"/Files/Files/PDF/{user.Name}-{listId}.pdf")); 72 response = $"/Files/Files/PDF/{user.Name}-{listId}.pdf"; 73 watch.Stop(); 74 logger.Log($"User ({user.ID}) generated a pdf of their favorite list ({listId}). [Path: {response}] [Execution took: {watch.ElapsedMilliseconds}ms]"); 75 } 76 } 77 else 78 { 79 logger.Log("No list ID supplied"); 80 response = "no {listid} supplied"; 81 } 82 } 83 @response