Getting the size of pixmap needed to get a paint of a full HTML document

Piotr Szymański niedakh at gmail.com
Fri Aug 12 22:32:20 CEST 2005


Hello,
I want to paint a HTML document on a QPixmap, full render of it, I need to 
know the size that the QPixmap will have (i need to have this size to specify 
the pagesize too), currently Im using:

bool TGenerator::loadDocument( const QString & fileName, QValueVector< 
KPDFPage * > & pagesVector )
{
    m_file=new CHMFile (fileName);
    m_file->ParseAndFillTopicsTree (&m_docSyn);

    QPrinter p; 
    p.setPageSize(static_cast< QPrinter::PageSize 
>( KGlobal::locale()->pageSize() ));
    p.setFullPage(true);
    QPaintDeviceMetrics m(&p);
    m_size = QSize(m.width(),m.height());

    pagesVector.resize(m_file->m_PageUrl.count());

    QMap <QString, int>::ConstIterator it=m_file->m_PageUrl.begin(), 
end=m_file->m_PageUrl.end();
    KHTMLPart *m_syncGen = new KHTMLPart();
    while (it!=end)
    {
        QString page;
        m_file->GetFileContentAsString (page,it.key());
        m_syncGen->begin();
        m_syncGen->write(page);
        m_syncGen->end();
        m_syncGen->view()->resize(m_size);
        m_syncGen->view()->layout();
        int i=it.data()-1;
        pagesVector[ i - 1 ] = new KPDFPage (it.data()-1, 
m_syncGen->view()->contentsWidth(),
            m_syncGen->view()->contentsHeight(),0);
        ++it;
    }
    return true;
}

Is there a faster way?

-- 
Piotr Szymański
niedakh at gmail.com
CS student at Faculty of Fundamental Problems of Technology, 
Wroclaw University of technology, Poland


More information about the Kde-soc mailing list