2

after converting into pdf I am trying to convert html to pdf using Itext7. I want bootstrap css to be included in pdf. I am trying to set baseuri but it is not working. here is my code :

using (MemoryStream stream = new System.IO.MemoryStream())
    {
        ConverterProperties properties = new ConverterProperties();
        properties.SetBaseUri("/css/"); // I tried this in many ways 
        properties.SetFontProvider(new DefaultFontProvider(true, true, true));
        HtmlConverter.ConvertToPdf(GridHtml, new PdfWriter(stream), properties);
        return File(stream.ToArray(), "application/pdf", "test1.pdf");
    }

this is the view before downloading in browser

Praym
  • 1,938
  • 22
  • 20

1 Answers1

1

include your css file in html content like this <link rel="stylesheet" type="text/css" href="mycss.css"/>

and set base uri of your css content

ConverterProperties properties = new ConverterProperties();
properties.SetBaseUri("Content//css//");
Raj K
  • 418
  • 4
  • 10