QT html and CSS to create pdf without QWebEngineView
<p>I want to create a pdf file from html and CSS file. Currently I am trying with QT using QWebView as QwebEngineView is not supported for Ubuntu as there is not MVC2013 or chromium.</p>

<p>I want the creator to be platform independent. I am showing all code here</p>

<pre><code>QDir::setCurrent(QCoreApplication::applicationDirPath());

    QFile  htmlFile ("myhtml.html");
    if (!htmlFile.open(QIODevice::ReadOnly | QIODevice::Text)){
        return -1;
    }


    QWebView *pWebView = new QWebView();
    pWebView-&gt;load( QUrl::fromLocalFile(QFileInfo(htmlFile).path()) );


    QPrinter printer(QPrinter::HighResolution);
    printer.setPageSize(QPrinter::A4);
    printer.setOutputFormat(QPrinter::PdfFormat);

    printer.setOutputFileName("output.pdf");

    pWebView-&gt;print(&amp;printer);
    delete pWebView;
</code></pre>

<p>The html file is as follows</p>

<pre><code>&lt;html&gt;

&lt;head&gt;
    &lt;link rel="stylesheet" href="style.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt; &lt;center&gt; ULTRA TECH LABORATORIES PRIVATE LIMITED &lt;/center&gt; &lt;/h1&gt;
    &lt;h3&gt; &lt;center&gt; CLOTH MARKET, G.E. ROAD KUMHARI, DIST-DRUG(C.G.) &lt;/center&gt; &lt;/h3&gt;
    &lt;h1&gt; &lt;center&gt; TLD MONITORING SERVICE - DOSE REPORT &lt;/center&gt; &lt;/h1&gt;
    &lt;p&gt;
        INSTITUTION NO. 017303
        &lt;span&gt;SERVICE PERIOD: APR-JUN 2012&lt;/span&gt;
    &lt;/p&gt;
    &lt;p&gt;
        ASHOK LABORATORY, KOLKATA
        &lt;span&gt;SERVICE FREQUENCY: QUARTERLY&lt;/span&gt;
    &lt;/p&gt;
    &lt;center&gt;
        &lt;ul&gt;
        &lt;li&gt;lorem ipsum dolor&lt;/li&gt;
        &lt;li&gt;sit amet&lt;/li&gt;
        &lt;li&gt;foo&lt;/li&gt;
        &lt;li&gt;bar&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/center&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p>The CSS file is as follows</p>

<pre><code>  ul {
    width: 500px;
    }
li {
      width: 50%;
      float: left;
      border: 1px solid #000;
      margin: 0;
      list-style-type: none;
      box-sizing: border-box;
}
li:nth-child(odd) {
    clear: left;
}

p {
    text-align:left;
}
span {
    float:right;
}
</code></pre>