title: how to convert this HTML file into a PDF using python
body: <p>I am having a process where my python code needs to generate a PDF.</p>
  <p>I have an HTML file as follows:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;./proforma_supply_bill.css&quot;&gt;
      &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot;&gt;
      &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Karla:wght@400;600;700&amp;family=Rajdhani:wght@700&amp;display=swap&quot;
          rel=&quot;stylesheet&quot;&gt;
      &lt;title&gt;Proforma bill of supply&lt;/title&gt;
      &lt;style&gt;
          body {
              font-family: &quot;Karla&quot;, sans-serif;
              margin: 0;
              padding: 0;
              box-sizing: border-box;
              overflow-x: hidden;
          }
  
          th,
          td {
              padding: 0 !important;
              text-align: left;
              position: relative;
          }
  
          .mb-3 {
              margin-bottom: 3px;
          }
  
          .mb-5 {
              margin-bottom: 5px;
          }
  
          .pr-10{
              padding-right: 10px !important;
          }
  
          .text-right {
              text-align: right;
          }
  
          .border-b_color {
              border-bottom: 1px solid #93d150;
          }
  
          .border-t {
              border-top: 1px solid #dedede;
          }
  
          .border-b {
              border-bottom: 1px solid #dedede;
          }
  
          .card {
              background-color: #fff;
              padding: 0 20px;
          }
  
          .card__header,
          .card__total_amount,
          .card__amount_section {
              display: flex;
              align-items: center;
              justify-content: space-between;
              padding: 17px 0;
          }
  
          .card__header_img {
              width: 175px;
          }
  
          .card__header_title {
              font-family: &quot;Rajdhani&quot;, sans-serif;
              font-size: 24px;
              font-weight: bold;
              color: #2b9eaa;
              text-transform: uppercase;
          }
  
          .card__info_flex {
              display: flex;
              padding: 10px 0;
          }
  
          .card__info {
              flex: 50%;
          }
  
          .card__info_row:not(:last-child) {
              margin-bottom: 5px;
          }
  
          .card__info_title,
          .card__table_data_row__content {
              color: #141414;
              font-size: 15px;
          }
  
          .card__info_text {
              color: #141414;
              font-size: 15px;
              font-weight: bold;
          }
  
          .card__table {
              width: 100%;
              border-collapse: collapse;
          }
  
          .card__table_header_row {
              background-color: #2b9eaa;
          }
  
          .card__table_data_row {
              border-top: 1px solid #dedede;
          }
  
          .card__table_header_row__content {
              color: #fff;
              font-size: 15px;
              font-weight: bold;
              padding: 6px 0;
          }
  
          .card__table_data_row__content {
              padding: 5px 0;
          }
  
          .card__table_data_row__subcontent {
              font-size: 13px;
              color: #141414;
              width: max-content;
              margin-left: 10px;
          }
  
          .dashed_b-t {
              border-top: 1px dashed #dedede;
          }
  
          .card__total_amount {
              background-color: #F2F2F2;
              padding: 4px 10px 5px;
              border-top: 1px solid #dedede;
              border-bottom: 1px solid #dedede;
          }
  
          .card__amount_section {
              padding: 6px 10px 5px;
              align-items: flex-start;
          }
  
          .card__total_amount__title,
          .card__total_amount__title_lg {
              font-size: 18px;
              color: #141414;
              font-weight: bold;
          }
  
          .card__declaration {
              padding: 6px 10px 5px;
              background-color: #D4ECEE;
              font-size: 15px;
              font-weight: bold;
              color: #2b2b2b;
          }
  
          .card__signature {
              margin-top: 30px;
              padding: 0 10px;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class=&quot;card&quot;&gt;
          &lt;div class=&quot;card__header border-b_color&quot;&gt;
              &lt;img src=&quot;https://res.cloudinary.com/exportify/image/upload/v1573547246/ExportifyLogo/exportify_logo_166x31_OG_yhqmrg.svg&quot;
                  alt=&quot;Exportify Logo&quot; class=&quot;card__header_img&quot;&gt;
              &lt;div class=&quot;card__header_title&quot;&gt;PROFORMA Bill of Supply&lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__info_flex border-b_color&quot;&gt;
              &lt;div class=&quot;card__info&quot;&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Proforma Invoice No.: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{PROFORMA_INV_NO}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Reference No. &amp; Date.: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{REF_NO}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Buyer's Order No.: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{BUYER_ORDER_NO}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Vessel/Flight No.: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{VESSEL_NAME}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;City/Port of Loading: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{POL}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Terms of Delivery: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{DELIVERY_TERMS}}&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class=&quot;card__info&quot;&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Dated: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{INV_DATE}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;SAIL Date: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{SAIL_DATE}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Place of Receipt by Shipper: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{PLACE_OF_RECEIPT}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;City/Port of Discharge: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{POD}}&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__info_flex&quot; style=&quot;padding-bottom: 0;&quot;&gt;
              &lt;div class=&quot;card__info&quot;&gt;&lt;/div&gt;
              &lt;div class=&quot;card__info mb-3&quot;&gt;
                  &lt;span class=&quot;card__info_title&quot;&gt;Buyer (Bill to)&lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__info_flex&quot; style=&quot;padding-top: 0;&quot;&gt;
              &lt;div class=&quot;card__info&quot;&gt;
                  &lt;div class=&quot;card__info_text mb-3&quot;&gt;XPORTIFY TECHNOLOGIES PRIVATE LIMITED&lt;/div&gt;
                  &lt;div class=&quot;card__info_title mb-5&quot; style=&quot;line-height: 20px; width: 85%;&quot;&gt;
                      3rd Floor, 313-314, A/3, BGTA Ganga Premises, Wadala Truck Terminal, Near Wadala RTO, Wadala East,
                      Mumbai
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;GSTIN/UIN: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;27AAACX2283M1ZX&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;PAN No: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;AAACX2283M&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_title mb-5&quot;&gt;State Name: Maharashtra, Code: 27&lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;CIN: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;U74999MH2017PTC295494&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;card__info&quot;&gt;
                  &lt;div class=&quot;card__info_text mb-3&quot;&gt;{{BUYER_COMPANY_NAME}}&lt;/div&gt;
                  &lt;div class=&quot;card__info_title mb-5&quot; style=&quot;line-height: 20px;&quot;&gt;
                      {{BUYER_ADDRESS}}
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;GSTIN/UIN: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{BUYER_GST}}&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;card__info_title mb-5&quot;&gt;State Name: {{BUYER_STATE}}&lt;/div&gt;
                  &lt;div class=&quot;card__info_row&quot;&gt;
                      &lt;span class=&quot;card__info_title&quot;&gt;Place of Supply: &lt;/span&gt;
                      &lt;span class=&quot;card__info_text&quot;&gt;{{BUYER_PLACE_OF_SUPPLY}}&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;table class=&quot;card__table mb-5&quot;&gt;
              &lt;thead&gt;
                  &lt;tr class=&quot;card__table_header_row&quot;&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content&quot; style=&quot;padding-left: 10px;&quot;&gt;Sr. No.&lt;/div&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content&quot;&gt;Description of Services&lt;/div&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content&quot;&gt;HSN/SAC&lt;/div&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content&quot;&gt;Quantity&lt;/div&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content&quot;&gt;Rate&lt;/div&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content&quot;&gt;Per&lt;/div&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;div class=&quot;card__table_header_row__content text-right&quot; style=&quot;padding-right: 10px;&quot;&gt;
                              Amount
                          &lt;/div&gt;
                      &lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;tr class=&quot;card__table_data_row&quot;&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content&quot; style=&quot;padding-left: 10px;&quot;&gt;1&lt;/div&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content&quot;&gt;Freight Charges&lt;/div&gt;
                          &lt;div class=&quot;card__table_data_row__subcontent&quot;&gt;$ 1938/20x1x@74.97&lt;/div&gt;
                          
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content&quot;&gt;996521&lt;/div&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content&quot;&gt;1&lt;/div&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content&quot;&gt;7,900.00&lt;/div&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content&quot;&gt;Container&lt;/div&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;div class=&quot;card__table_data_row__content text-right pr-10&quot; style=&quot;right: 0;&quot;&gt;USD
                              7,900.00
                          &lt;/div&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
  
          &lt;div class=&quot;card__total_amount mb-5&quot;&gt;
              &lt;div class=&quot;card__total_amount__title&quot;&gt;Total&lt;/div&gt;
              &lt;div class=&quot;card__total_amount__title_lg&quot;&gt;USD 7,900.00&lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__amount_section border-b mb-3&quot;&gt;
              &lt;div class=&quot;card__amount_section_flex&quot;&gt;
                  &lt;div class=&quot;card__info_title mb-3&quot;&gt;Amount Chargeable (in words)&lt;/div&gt;
                  &lt;div class=&quot;card__info_text&quot;&gt;USD Seven Thousand Nine Hundred Only&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;card__amount_section_flex&quot;&gt;
                  &lt;div class=&quot;card__info_title&quot;&gt;E &amp; O.E&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__amount_section border-t&quot;&gt;
              &lt;div class=&quot;card__amount_section_flex&quot;&gt;
                  &lt;div class=&quot;card__info_title&quot;&gt;HSN/SAC&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;card__amount_section_flex&quot;&gt;
                  &lt;div class=&quot;card__info_title&quot;&gt;Taxable Value&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__amount_section border-t mb-3&quot;&gt;
              &lt;div class=&quot;card__amount_section_flex&quot;&gt;
                  &lt;div class=&quot;card__info_title&quot;&gt;996521&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;card__amount_section_flex&quot;&gt;
                  &lt;div class=&quot;card__info_title&quot;&gt;INR 1,45,291.86&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__total_amount mb-5&quot;&gt;
              &lt;div class=&quot;card__total_amount__title&quot; style=&quot;font-size: 15px;&quot;&gt;Total&lt;/div&gt;
              &lt;div class=&quot;card__total_amount__title_lg&quot; style=&quot;font-size: 15px;&quot;&gt;INR 1,45,291.86&lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__info_row&quot; style=&quot;padding: 10px;&quot;&gt;
              &lt;span class=&quot;card__info_title&quot;&gt;Tax Amount (in words): &lt;/span&gt;
              &lt;span class=&quot;card__info_text&quot;&gt;NIL&lt;/span&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;card__declaration&quot;&gt;
              Declaration
          &lt;/div&gt;
  
          &lt;div class=&quot;card__info_title&quot; style=&quot;padding: 10px;&quot;&gt;
              We declare that this invoice shows the actual price of the goods described and that all particulars are true
              and correct.
          &lt;/div&gt;
  
          &lt;div class=&quot;card__info_text&quot; style=&quot;padding: 0 10px;&quot;&gt;
              for XPORTIFY TECHNOLOGIES PRIVATE LIMITED
          &lt;/div&gt;
  
          &lt;div class=&quot;card__signature&quot;&gt;
              &lt;div class=&quot;card__info_title&quot;&gt;Authorised Signatory&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>I want to convert this HTML file into a PDF using Python.
  I have one option of using <strong>wkhtmltopdf</strong> package but I have to run it using the command line everytime.
  Which is the most optimal way of doing this without hampering the flow of my code?</p>