title: Itext7 HTML to PDF conversion using Html2pdf when HTML is passed as input string and CSS as file
body: <p>I have already implemented the HTML to PDF conversion via Itext 5 XMLWorker. Please find the code below:</p>
  
  <pre><code>using (var ms = new MemoryStream())
  using (var document = new Document())
  {
   using (var writer = PdfWriter.GetInstance(document, ms))
   {
    document.Open();
    document.SetMargins(30, 60, 60, 60);
    using (var strReader = new StringReader(htmlToExport))
    {
      //Set factories
      var htmlContext = new HtmlPipelineContext(null);
      htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
      //Set css
      var cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver   (false);
      // cssResolver.AddCssFile(HttpContext.Current.Server.MapPath  ("~/Content/bootstrap.min.css"),
      //    true);
      cssResolver.AddCssFile("http://localhost:8902/Content/bootstrap.css", true);
      //Export
      var pipeline = new CssResolverPipeline(cssResolver,
      new HtmlPipeline(htmlContext, new PdfWriterPipeline(document, writer)));
      var worker = new XMLWorker(pipeline, true);
      var xmlParse = new XMLParser(true, worker);
      xmlParse.Parse(strReader);
      xmlParse.Flush();
    }
    document.Close();
    }
  }
  </code></pre>
  
  <p>I am unable to find the relevant example to full fill above requirement in Itext7.</p>