{"id":393,"date":"2024-04-13T17:39:30","date_gmt":"2024-04-13T17:39:30","guid":{"rendered":"https:\/\/html2pdfrocket.com\/blog\/?p=393"},"modified":"2024-09-29T12:26:55","modified_gmt":"2024-09-29T12:26:55","slug":"convert-csharp-to-pdf","status":"publish","type":"post","link":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/","title":{"rendered":"C# examples to convert HTML to PDF in .Net"},"content":{"rendered":"\n<div class=\"wp-block-group has-global-padding is-content-justification-center is-layout-constrained wp-block-group-is-layout-constrained\" style=\"border-top-color:var(--wp--preset--color--contrast-2);border-top-style:dashed;border-top-width:1px;border-bottom-color:var(--wp--preset--color--contrast-2);border-bottom-style:dotted;border-bottom-width:1px;margin-bottom:var(--wp--preset--spacing--10);padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)\">\n<h4 class=\"wp-block-heading has-text-align-center\">Get Started<\/h4>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">Don&#8217;t waste your day reinventing the wheel, be converting in 3 minutes from now<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-190e7bf0 wp-block-buttons-is-layout-flex\" style=\"margin-top:0.5rem;margin-bottom:0.5rem\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/account\/register\">GET YOUR FREE API KEY<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">If you are looking for a C# webpage to pdf converter, you can use our free web service, in use by commercial applications and platforms. You do not need to install or download any libraries or components to make this work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Especially great for reporting, brochures and invoicing &#8211; create one HTML webpage and use it as both as a source to generate your downloadable PDF or for users to view directly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The service will convert webpages to pdfs online by reading your webpage and dynamically generate a PDF or an image. It will handle fairly complex documents and layouts including images and executing javascript, although as always the simpler the better.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">See example #5 for a the new ASPNET 5 code.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #1 &#8211; How to stream a PDF directly to the end user with ASP.NET C# MVC<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">By commenting out line #17 you can switch between showing the file inside the browser window itself (if supported by the browser), and downloading as an attachment.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/1d1bd00b6d788f52a27156011eb53db3.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #2 &#8211; How to convert an HTML string to a PDF using ASP.NET C#<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Line #12 allows you to change the default output format so the html is converted into an image. You can use &#8220;png&#8221;, &#8220;bmp&#8221; or &#8220;svg&#8221; formats for images. You could add line #12 to the above example to steam the image to the user (or as an attachment), or you can use this example which instead saves the image to your disk.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/d41e3c43c138c21031e9a9520a0fccb6.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #3 &#8211; How to convert an HTML string to a PDF using ASP.NET C#<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">You can also convert an HTML string to a PDF by supplying the HTML directly. It can be as complex as you like and may include image references and stylesheeet information &#8212; just make sure it is valid HTML<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/e507b346a6b96ea674face1196f85498.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #4 &#8211; Using C# MVC to convert a URL and add a footer<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">By default page margins are set to zero. In this example, we increase the bottom margin to 30 to allow space for a page footer. Note you could use a Url to the file, or you could pass the whole file as a string with the FooterHtml parameter<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/9a8b7b8fadfdfa050c31e70d066017db.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Here is an example custom HTML footer file with page numbers. Do not forget the doctype.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/737a42e709d33ed88a01d453edc8a88e.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">This is an example which hides the header on page 1 and 3<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/a9d7db0837cf9937befa24e21dabeb17.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #5 &#8211; How to convert a webpage to an PDF and stream it to the browser using ASP.NET C#<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Line #20 allows you to stream the bytes directly to the browser to use as an attachment<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/29122f077b0a2af0d928fd1eeddf5e61.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #6 &#8211; ASP.NET 5 and C# MVC 6<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">The WebClient has been replaced with HttpClient in ASP.NET 5. Other aspects follow the same format.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/5989428556e5a5c1fcaf772d746783ea.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example #7 &#8211; Batch\/Asynchronous Process<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">For PDF conversion taking more than 30 seconds or input\/output files more than 6 Mb, you need to use the batch\/asynchronous parameters.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/90d97021d1a491891cc83da03a9ee6f0.js\"><\/script>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Need another PHP example? Would you mind dropping us a&nbsp;<a href=\"https:\/\/html2pdfrocket.com\/contact\">quick one line note<\/a>&nbsp;to say which example you would have liked and we&#8217;ll put the most commonly used ones here.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">\n<h4 class=\"wp-block-heading\">About HTML2PDF Rocket<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\"><a href=\"https:\/\/html2pdfrocket.com\/\">Html2PDF Rocket<\/a>&nbsp;is based on an open source technology. It is a free and easy to use web service to convert html webpages into PDF files or images. HTML2PDF Rocket is trusted by over 10,500 companies worldwide.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What is an HTML to PDF API?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">An HTML to PDF API is a web service that will read your webpage and dynamically generate a PDF or an image. It will convert the contents of a webpage to a PDF file. It handles fairly complex documents and layouts, including images.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Why Convert HTML to PDF?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Converting HTML to PDF is great for reporting, creating brochures, and printing invoices. Just create one HTML or PHP webpage, and use it as a source to generate downloadable PDF or viewable PDF pages. PDF is a fixed-layout document created by&nbsp;<a href=\"https:\/\/www.adobe.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Adobe Systems<\/a>. It is a perfect document for downloading text or HTML content in a file, with consistent layout that does not depend on the device for viewing and does not require internet connection.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-content-justification-center is-layout-constrained wp-block-group-is-layout-constrained\" style=\"border-top-color:var(--wp--preset--color--contrast-2);border-top-style:dashed;border-top-width:1px;border-bottom-color:var(--wp--preset--color--contrast-2);border-bottom-style:dotted;border-bottom-width:1px;margin-bottom:var(--wp--preset--spacing--10);padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)\">\n<h4 class=\"wp-block-heading has-text-align-center\">Try HTML2PDF Rocket for FREE<\/h4>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-190e7bf0 wp-block-buttons-is-layout-flex\" style=\"margin-top:0.5rem;margin-bottom:0.5rem\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/account\/register\">GET YOUR FREE API KEY<\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">and start converting HTML to PDF instantly!<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignwide has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<div style=\"height:55px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading has-text-align-center\">Conversion Tip<\/h4>\n\n\n\n<div style=\"height:19px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-text-align-center has-heading-font-family has-medium-font-size wp-block-paragraph\" style=\"font-style:normal;font-weight:400;line-height:1.2\">The number #1 reason a conversion fails to come out how you expect is because it contains references to external links or images that don&#8217;t exist &#8211; or you are trying to link to localhost! If there is a conversion error, please check the page using your web browsers &#8216;developer&#8217; network tab to ensure there are no 404 errors.<\/p>\n\n\n\n<div style=\"height:55px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you are looking for a C# webpage to pdf converter, you can use our free web service, in use by commercial applications and platforms. You do not need to install or download any libraries or components to make this work. Especially great for reporting, brochures and invoicing &#8211; create one HTML webpage and use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":397,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-examples"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C# examples to convert HTML to PDF in .Net - HTML2PDFRocket<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# examples to convert HTML to PDF in .Net - HTML2PDFRocket\" \/>\n<meta property=\"og:description\" content=\"If you are looking for a C# webpage to pdf converter, you can use our free web service, in use by commercial applications and platforms. You do not need to install or download any libraries or components to make this work. Especially great for reporting, brochures and invoicing &#8211; create one HTML webpage and use [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML2PDFRocket\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-13T17:39:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-29T12:26:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/04\/StockCake-Coding-Workspace-Setup.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"willie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"willie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/\"},\"author\":{\"name\":\"willie\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/person\\\/7fdf75521bc4c44d3e39cde19dddc776\"},\"headline\":\"C# examples to convert HTML to PDF in .Net\",\"datePublished\":\"2024-04-13T17:39:30+00:00\",\"dateModified\":\"2024-09-29T12:26:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/\"},\"wordCount\":508,\"publisher\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/StockCake-Coding-Workspace-Setup.jpg\",\"articleSection\":[\"Code Examples\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/\",\"name\":\"C# examples to convert HTML to PDF in .Net - HTML2PDFRocket\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/StockCake-Coding-Workspace-Setup.jpg\",\"datePublished\":\"2024-04-13T17:39:30+00:00\",\"dateModified\":\"2024-09-29T12:26:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#primaryimage\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/StockCake-Coding-Workspace-Setup.jpg\",\"contentUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/StockCake-Coding-Workspace-Setup.jpg\",\"width\":1024,\"height\":1024},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-csharp-to-pdf\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# examples to convert HTML to PDF in .Net\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/\",\"name\":\"HTML 2 PDF ROCKET\",\"description\":\"An easy to use web service to convert HTML webpage to PDF\",\"publisher\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#organization\",\"name\":\"HTML 2 PDF ROCKET\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/logo.png\",\"width\":270,\"height\":48,\"caption\":\"HTML 2 PDF ROCKET\"},\"image\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/person\\\/7fdf75521bc4c44d3e39cde19dddc776\",\"name\":\"willie\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g\",\"caption\":\"willie\"},\"sameAs\":[\"https:\\\/\\\/html2pdfrocket.com\\\/blog\"],\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/author\\\/willie\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# examples to convert HTML to PDF in .Net - HTML2PDFRocket","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/","og_locale":"en_US","og_type":"article","og_title":"C# examples to convert HTML to PDF in .Net - HTML2PDFRocket","og_description":"If you are looking for a C# webpage to pdf converter, you can use our free web service, in use by commercial applications and platforms. You do not need to install or download any libraries or components to make this work. Especially great for reporting, brochures and invoicing &#8211; create one HTML webpage and use [&hellip;]","og_url":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/","og_site_name":"HTML2PDFRocket","article_published_time":"2024-04-13T17:39:30+00:00","article_modified_time":"2024-09-29T12:26:55+00:00","og_image":[{"width":1024,"height":1024,"url":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/04\/StockCake-Coding-Workspace-Setup.jpg","type":"image\/jpeg"}],"author":"willie","twitter_card":"summary_large_image","twitter_misc":{"Written by":"willie","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#article","isPartOf":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/"},"author":{"name":"willie","@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/person\/7fdf75521bc4c44d3e39cde19dddc776"},"headline":"C# examples to convert HTML to PDF in .Net","datePublished":"2024-04-13T17:39:30+00:00","dateModified":"2024-09-29T12:26:55+00:00","mainEntityOfPage":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/"},"wordCount":508,"publisher":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#organization"},"image":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#primaryimage"},"thumbnailUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/04\/StockCake-Coding-Workspace-Setup.jpg","articleSection":["Code Examples"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/","url":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/","name":"C# examples to convert HTML to PDF in .Net - HTML2PDFRocket","isPartOf":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#primaryimage"},"image":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#primaryimage"},"thumbnailUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/04\/StockCake-Coding-Workspace-Setup.jpg","datePublished":"2024-04-13T17:39:30+00:00","dateModified":"2024-09-29T12:26:55+00:00","breadcrumb":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#primaryimage","url":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/04\/StockCake-Coding-Workspace-Setup.jpg","contentUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/04\/StockCake-Coding-Workspace-Setup.jpg","width":1024,"height":1024},{"@type":"BreadcrumbList","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-csharp-to-pdf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/html2pdfrocket.com\/blog\/"},{"@type":"ListItem","position":2,"name":"C# examples to convert HTML to PDF in .Net"}]},{"@type":"WebSite","@id":"https:\/\/html2pdfrocket.com\/blog\/#website","url":"https:\/\/html2pdfrocket.com\/blog\/","name":"HTML 2 PDF ROCKET","description":"An easy to use web service to convert HTML webpage to PDF","publisher":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/html2pdfrocket.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/html2pdfrocket.com\/blog\/#organization","name":"HTML 2 PDF ROCKET","url":"https:\/\/html2pdfrocket.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png","contentUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png","width":270,"height":48,"caption":"HTML 2 PDF ROCKET"},"image":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/person\/7fdf75521bc4c44d3e39cde19dddc776","name":"willie","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g","caption":"willie"},"sameAs":["https:\/\/html2pdfrocket.com\/blog"],"url":"https:\/\/html2pdfrocket.com\/blog\/author\/willie\/"}]}},"_links":{"self":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts\/393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/comments?post=393"}],"version-history":[{"count":3,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts\/393\/revisions"}],"predecessor-version":[{"id":398,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts\/393\/revisions\/398"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/media\/397"}],"wp:attachment":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/media?parent=393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/categories?post=393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/tags?post=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}