Esempio n. 1
0
void TestFontsData::checkSecondDocumentQuery()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load("../../../test/tests/type3.pdf");
    QVERIFY( doc );

    QList<Poppler::FontInfo> listOfFonts = doc->fonts();
    QCOMPARE( listOfFonts.size(), 2 );
    // check we get the very same result when calling fonts() again (#19405)
    QList<Poppler::FontInfo> listOfFonts2 = doc->fonts();
    QCOMPARE( listOfFonts, listOfFonts2 );

    delete doc;
}
Esempio n. 2
0
void TestFontsData::checkScanForFonts()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load("../../../test/tests/fonts.pdf");
    QVERIFY( doc );

    QList<Poppler::FontInfo> listOfFonts = doc->fonts();
    QCOMPARE( listOfFonts.size(), 3 );
    // check we get the very same result when gatering fonts using scanForFonts
    QList<Poppler::FontInfo> listOfFonts2;
    for ( int i = 0; i < doc->numPages(); ++i )
    {
        doc->scanForFonts( 1, &listOfFonts2 );
    }
    QCOMPARE( listOfFonts, listOfFonts2 );

   // check doing a second scanForFonts gives no result
    QList<Poppler::FontInfo> listOfFonts3;
    for ( int i = 0; i < doc->numPages(); ++i )
    {
        doc->scanForFonts( 1, &listOfFonts3 );
    }
    QVERIFY( listOfFonts3.isEmpty() );

    delete doc;
}
Esempio n. 3
0
void TestFontsData::checkNoFonts()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load("../../../test/tests/image.pdf");
    QVERIFY( doc );

    QList<Poppler::FontInfo> listOfFonts = doc->fonts();
    QCOMPARE( listOfFonts.size(), 0 );

    delete doc;
}
Esempio n. 4
0
int main( int argc, char **argv )
{
    QApplication a( argc, argv );               // QApplication required!

    if ( argc != 3)
    {
	qWarning() << "usage: test-password-qt4 owner-password filename";
	exit(1);
    }
  
    Poppler::Document *doc = Poppler::Document::load(argv[2], argv[1]);
    if (!doc)
    {
	qWarning() << "doc not loaded";
	exit(1);
    }
  
    // output some meta-data
    int major = 0, minor = 0;
    doc->getPdfVersion( &major, &minor );
    qDebug() << "    PDF Version: " << qPrintable(QString::fromLatin1("%1.%2").arg(major).arg(minor));
    qDebug() << "          Title: " << doc->info("Title");
    qDebug() << "        Subject: " << doc->info("Subject");
    qDebug() << "         Author: " << doc->info("Author");
    qDebug() << "      Key words: " << doc->info("Keywords");
    qDebug() << "        Creator: " << doc->info("Creator");
    qDebug() << "       Producer: " << doc->info("Producer");
    qDebug() << "   Date created: " << doc->date("CreationDate").toString();
    qDebug() << "  Date modified: " << doc->date("ModDate").toString();
    qDebug() << "Number of pages: " << doc->numPages();
    qDebug() << "     Linearised: " << doc->isLinearized();
    qDebug() << "      Encrypted: " << doc->isEncrypted();
    qDebug() << "    OK to print: " << doc->okToPrint();
    qDebug() << "     OK to copy: " << doc->okToCopy();
    qDebug() << "   OK to change: " << doc->okToChange();
    qDebug() << "OK to add notes: " << doc->okToAddNotes();
    qDebug() << "      Page mode: " << doc->pageMode();
    QStringList fontNameList;
    foreach( const Poppler::FontInfo &font, doc->fonts() )
	fontNameList += font.name();
    qDebug() << "          Fonts: " << fontNameList.join( ", " );

    Poppler::Page *page = doc->page(0);
    qDebug() << "    Page 1 size: " << page->pageSize().width()/72 << "inches x " << page->pageSize().height()/72 << "inches";

    PDFDisplay test( doc );        // create picture display
    test.setWindowTitle("Poppler-Qt4 Test");
    test.show();                            // show it

    return a.exec();                        // start event loop
}
Esempio n. 5
0
void TestFontsData::checkType1()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load("../../../test/tests/text.pdf");
    QVERIFY( doc );

    QList<Poppler::FontInfo> listOfFonts = doc->fonts();
    QCOMPARE( listOfFonts.size(), 1 );
    QCOMPARE( listOfFonts.at(0).name(), QString("Helvetica") );
    QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::Type1 );
    QCOMPARE( listOfFonts.at(0).typeName(), QString("Type 1") );

    QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
    QCOMPARE( listOfFonts.at(0).isSubset(), false );

    delete doc;
}
Esempio n. 6
0
void TestFontsData::checkTrueType()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load("../../../test/unittestcases/truetype.pdf");
    QVERIFY( doc );

    QList<Poppler::FontInfo> listOfFonts = doc->fonts();
    QCOMPARE( listOfFonts.size(), 2 );
    QCOMPARE( listOfFonts.at(0).name(), QString("Arial-BoldMT") );
    QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::TrueType );
    QCOMPARE( listOfFonts.at(0).typeName(), QString("TrueType") );

    QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
    QCOMPARE( listOfFonts.at(0).isSubset(), false );

    QCOMPARE( listOfFonts.at(1).name(), QString("ArialMT") );
    QCOMPARE( listOfFonts.at(1).type(), Poppler::FontInfo::TrueType );
    QCOMPARE( listOfFonts.at(1).typeName(), QString("TrueType") );

    QCOMPARE( listOfFonts.at(1).isEmbedded(), false );
    QCOMPARE( listOfFonts.at(1).isSubset(), false );

    delete doc;
}
Esempio n. 7
0
int main( int argc, char **argv )
{
    QCoreApplication a( argc, argv );               // QApplication required!

    if (!( argc == 2 ))
    {
	qWarning() << "usage: poppler-fonts filename";
	exit(1);
    }
  
    Poppler::Document *doc = Poppler::Document::load(argv[1]);
    if (!doc)
    {
	qWarning() << "doc not loaded";
	exit(1);
    }

    std::cout << "name                                 type         emb sub font file";
    std::cout << std::endl;
    std::cout << "------------------------------------ ------------ --- --- ---------";
    std::cout << std::endl;
  
    foreach( const Poppler::FontInfo &font, doc->fonts() ) {
	if (font.name().isNull()) {
	    std::cout << qPrintable( QString("%1").arg(QString("[none]"), -37) );
	} else {
	    std::cout << qPrintable( QString("%1").arg(font.name(), -37) );
	}
	switch( font.type() ) {
	case Poppler::FontInfo::unknown:
	    std::cout << "unknown           ";
	    break;
	case Poppler::FontInfo::Type1:
	    std::cout << "Type 1            ";
	    break;
	case Poppler::FontInfo::Type1C:
	    std::cout << "Type 1C           ";
	    break;
	case Poppler::FontInfo::Type3:
	    std::cout << "Type 3            ";
	    break;
	case Poppler::FontInfo::TrueType:
	    std::cout << "TrueType          ";
	    break;
	case Poppler::FontInfo::CIDType0:
	    std::cout << "CID Type 0        ";
	    break;
	case Poppler::FontInfo::CIDType0C:
	    std::cout << "CID Type 0C       ";
	    break;
	case Poppler::FontInfo::CIDTrueType:
	    std::cout << "CID TrueType      ";
	    break;
	case Poppler::FontInfo::Type1COT:
	    std::cout << "Type 1C (OT)      ";
	    break;
	case Poppler::FontInfo::TrueTypeOT:
	    std::cout << "TrueType (OT)     ";
	    break;
	case Poppler::FontInfo::CIDType0COT:
	    std::cout << "CID Type 0C (OT)  ";
	    break;
	case Poppler::FontInfo::CIDTrueTypeOT:
	    std::cout << "CID TrueType (OT) ";
	    break;
	}

	if ( font.isEmbedded() ) {
	    std::cout << "yes ";
	} else {
	    std::cout << "no  ";
	}
	if ( font.isSubset() ) {
	    std::cout << "yes ";
	} else {
	    std::cout << "no  ";
	}
	std::cout << qPrintable( QString("%1").arg(font.file()) );
	std::cout << std::endl;
    }
    delete doc;
}