Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. public void exportToPDF(string html){
  2.         // also you can get html file locally if u want
  3.         //string html = File.ReadAllText(@"C:\Users\adriatik.ademi\Desktop\me\test.html"); (change path)
  4.         HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
  5.         doc.LoadHtml(html);
  6.         var htmlHead = doc.DocumentNode.SelectSingleNode("//head");
  7.         HtmlNode newPara = HtmlNode.CreateNode("<style>* { direction:rtl; }</style>");
  8.         htmlHead.ChildNodes.Add(newPara);
  9.         html = doc.DocumentNode.InnerHtml;
  10.         IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
  11.         Renderer.RenderHtmlAsPdf(html).SaveAs(@"C:\Users\adriatik.ademi\Desktop\me\iron.pdf"); //you should change this path!
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement