title: Angular convert html to pdf with css
body: <p>I need to convert html to pdf with css, I used windows.print() but it doesn't include css styles  </p>
  <p>Html:</p>
  <pre><code>&lt;button type=&quot;submit&quot; (click)=&quot;generatePDFDescription()&quot;&gt;
  Generate Pdf
  &lt;/button&gt;
  &lt;div id=&quot;print-section&quot;&gt;
  ...
  &lt;/div&gt;
  </code></pre>
  <p>Component classe:</p>
  <pre><code>@Component({
    selector: 'app-generate-pdf-description',
    templateUrl: './generate-pdf-description.component.html',
    styleUrls: ['./generate-pdf-description.component.scss']
  })
  export class GeneratePdfDescriptionComponent implements OnInit {
  
    constructor() { }
  
    ngOnInit() {
    }
  
    generatePDFDescription(): void {
      const element: Element = document.getElementById('print-section');
      let myWindows = window.open('', 'PRINT', 'height=400,with=600');
      myWindows.document.write(&quot;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta charset='utf-8'&gt;&lt;meta http-equiv='X-UA-Compatible' content='IE=edge'&gt;&quot;+
      + &quot;&lt;meta name='viewport' content='width=device-width, initial-scale=1'&gt;&quot;
      + &quot;&lt;link rel='stylesheet' type='text/css' media='screen' href='./generate-pdf-description.component.scss'&gt;&quot;);
      myWindows.document.write('&lt;/head&gt;&lt;body&gt;');
      myWindows.document.write(element.innerHTML);
      myWindows.document.write('&lt;/body&gt;&lt;/html&gt;');
      myWindows.document.close();
      myWindows.focus();
      myWindows.print();
    }
  
  }
  </code></pre>
  <p>Result:</p>
  <p><a href="https://i.stack.imgur.com/2IGIX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2IGIX.png" alt="enter image description here" /></a></p>
  <p>Expected result:</p>
  <p><a href="https://i.stack.imgur.com/p38gN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p38gN.png" alt="enter image description here" /></a></p>