title: External CSS in Flying Saucer
body: <p>I would like to know how to include the External CSS in Flying-Saucer.Before that <em>THB</em> I checked with all the available links in <code>StackOverflow</code> but they are not helpful.That's the reason why made this one my self.</p>
  
  <p><code>TestCSS.xhtml</code> renamed version of <code>TestCSS.html</code>.So content of them are same.
  Below (Image 1 ) is the Structure of my Project  in Eclipse IDE.If I run the TestCSS.html it will give the page result as Image 2 in Browser.</p>
  
  <p><strong><em>Below are Code which are not working as External CSS :</em></strong></p>
  
  <pre><code>This one Working :
  &lt;style&gt;
  .redFontClass
  {
    color : red;
  }
  .blueFontClass
  {
    color : blue;
  }
  &lt;/style&gt;
  
  This one NOT Working :
  &lt;link href="RedCSS.css" rel="stylesheet" type="text/css" /&gt;
  
  This one NOT Working :
  &lt;link rel="stylesheet" 
  href="http://localhost:8888/Fly-Sauccer-Web/css/RedCSS.css" type="text/css" /&gt;
  
  This one NOT Working :
  &lt;link href="file:///C:/Users/Joseph.M/WorkPlace_Struts2/Fly-Sauccer-Web/WebContent/css/RedCSS.css"  rel="stylesheet" type="text/css" /&gt;
  </code></pre>
  
  <p>I tried with all the ways including absolute path of css inside of the xhtml also.but css is not getting applied.Please help me to fix the problem.</p>
  
  <p><strong><em>Image 1</em></strong></p>
  
  <p><img src="https://i.stack.imgur.com/Rfwm8.jpg" alt="enter image description here"></p>
  
  <p><strong><em>Image 2</em></strong></p>
  
  <p><img src="https://i.stack.imgur.com/AlOLt.jpg" alt="enter image description here"></p>
  
  <p><strong><em>RedCSS.css</em></strong> </p>
  
  <pre><code>.fontClass
  {
    color : red;
  }
  </code></pre>
  
  <p><strong><em>TestCSS.html</em></strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link href="file:///C:/Users/Joseph.M/WorkPlace_Struts2/Fly-Sauccer-Web/WebContent/css/RedCSS.css"  rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;b&gt;This Should come assss &lt;span class = "fontClass" &gt;Red&lt;/span&gt; &lt;/b&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Java Code :</strong></p>
  
  <pre><code>public static void main(String[] args) throws Exception{
  
      // Path of Input File 
      String inputFile = "C:\\Users\\Joseph.M\\WorkPlace_Struts2\\Fly-Sauccer-Web\\WebContent\\TestCSS.xhtml";
      // Path of Output File 
      String outputFile = "C:\\Users\\Joseph.M\\WorkPlace_Struts2\\Fly-Sauccer-Web\\output.pdf";
      OutputStream os = new FileOutputStream(outputFile);             
      ITextRenderer renderer = new ITextRenderer();
  
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      InputStream is = new ByteArrayInputStream(FileUtils.readFileToByteArray(new File(inputFile)));
      Document doc = builder.parse(is);
      is.close();
      renderer.setDocument(doc,null);        
      renderer.layout();
      renderer.createPDF(os);             
      os.close();
  }
  </code></pre>