Hi,

I have this little piece of code that print the content of a PDF file and
convert it to a sequence of image:

bool showPDF(const QString &fileName) {
        bool result = false;

        if (auto document = Poppler::Document::load(fileName)) {
                if (document->isLocked()) {
                        qCritical() << "Document is locked:" << fileName <<
"\n";
                } else {
                        qDebug() << "pages: " << document->numPages() <<
"\n";

                        for (int i = 0; i < document->numPages(); i++) {
                                qDebug() << "page:" << i << "\n";
                                auto page = document->page(i);

                                for (auto &text : page->textList()) {
                                        qDebug() << "\ttext: " <<
text->boundingBox().x()
                                                  << " / " <<
text->boundingBox().y()
                                                  << " " << text->text()
                                                  << "\n";
                                }

                                auto image = page->renderToImage(300, 300);
                                image.save(QString("%0.%1.jpg")
                                           .arg(fileName,

QString::number(i).rightJustified(3, '0')));
                                break;
                        }

                        for (auto font : document->fonts()) {
                                qDebug() << font.name();

                        }
                }
        }

        return result;
}

How can I extract text formatting information like boldness and font size ?
I can’t find the link between text and font items.

Martin

Reply via email to