<div dir="ltr"><div class="gmail_quote">Hi,<br><br>I have this little piece of code that print the content of a PDF file and convert it to a sequence of image:<br>
<br>
bool showPDF(const QString &fileName) {<br>
        bool result = false;<br>
<br>
        if (auto document = Poppler::Document::load(fileName)) {<br>
                if (document->isLocked()) {<br>
                        qCritical() << "Document is locked:" << fileName << "\n";<br>
                } else {<br>
                        qDebug() << "pages: " << document->numPages() << "\n";<br>
<br>
                        for (int i = 0; i < document->numPages(); i++) {<br>
                                qDebug() << "page:" << i << "\n";<br>
                                auto page = document->page(i);<br>
<br>
                                for (auto &text : page->textList()) {<br>
                                        qDebug() << "\ttext: " << text->boundingBox().x()<br>
                                                  << " / " << text->boundingBox().y()<br>
                                                  << " " << text->text()<br>
                                                  << "\n";<br>
                                }<br>
<br>
                                auto image = page->renderToImage(300, 300);<br>
                                image.save(QString("%0.%1.jpg")<br>
                                           .arg(fileName,<br>
                                                QString::number(i).rightJustified(3, '0')));<br>
                                break;<br>
                        }<br>
<br>
                        for (auto font : document->fonts()) {<br>
                                qDebug() << <a href="http://font.name" rel="noreferrer" target="_blank">font.name</a>();<br>
<br>
                        }<br>
                }<br>
        }<br>
<br>
        return result;<br>
}<br>
<br>
How can I extract text formatting information like boldness and font size ? I can’t find the link between text and font items.<br>
<br>
Martin</div></div>