title: Keeping CSS in Html to PDF export using Javascript
body: <p>I am trying to generate PDF using JavaScript but I am unable to generate on with CSS. I am currently using <a href="https://github.com/MrRio/jsPDF" rel="noreferrer">jsPDF</a>. The issue with jsPDF is that it takes away all the formatting. I don't need styles or colors but I need to have multiple <code>divs</code> side by side. </p>
  
  <p>My code is</p>
  
  <pre><code>                    margins = {
                          top: 0,
                          bottom: 0,
                          left: 20,
                          width: 170
                      };                       
                      pdf.setFontSize(6);
                      pdf.fromHTML(
                          $('#textpdfdiv').html(), 
                          margins.left, 
                          margins.top, { 
                              'width': margins.width
                          },
  
                          function (dispose) {                                
                              pdf.save('Export_Text.pdf');
                          }, margins
                      );
  </code></pre>
  
  <p><code>textpdfdiv</code> is an id of <code>div</code> that has all the values of form in separate <code>divs</code> side by side. But when I generate PDF, they go into separate row. </p>
  
  <p>I can't use <a href="https://github.com/Xportability/css-to-pdf" rel="noreferrer">XEPOnline</a> because it processes online. </p>
  
  <p>How I need PDF output is something like this (minus the colors and form fields etc)</p>
  
  <p><a href="https://i.stack.imgur.com/vmafo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vmafo.png" alt=""></a></p>
  
  <p><br><br>
  <strong>The output that I currently have is</strong> <br></p>
  
  <p><a href="https://i.stack.imgur.com/AcXi0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AcXi0.png" alt=""></a></p>
  
  <p>Is there any plugin that converts HTML+CSS to PDF? Or can I achieve this with jsPDF? I don't have a table so this <a href="https://stackoverflow.com/questions/37369661/export-html-css-to-pdf-using-javascript">Question</a> doesn't help as well.</p>
  
  <p><strong>EDIT:</strong> I can't use Html2Canvas as well because it creates long non searchable PDFs and I need searchable PDFs. Html2Canvas takes screenshot and it is an image but I need text that can be copied.</p>
  
  <p>Thank you,<br>
  Hamza</p>