Ejemplo n.º 1
0
std::map<CPLString, GDALPDFObject*>& GDALPDFDictionaryPoppler::GetValues()
{
    int i = 0;
    int nLength = m_poDict->getLength();
    for(i=0;i<nLength;i++)
    {
        Get((const char*)m_poDict->getKey(i));
    }
    return m_map;
}
Ejemplo n.º 2
0
bool PdfExport::addPopplerPage(XojPopplerPage* pdf, XojPopplerDocument doc)
{
    XOJ_CHECK_TYPE(PdfExport);

    Page* page = pdf->getPage();
    static int otherObjectId = 1;

    this->resources = page->getResourceDict();

    GList* replacementList = NULL;

    Dict* dict = page->getResourceDict();
    for (int i = 0; i < dict->getLength(); i++)
    {
        const char* cDictName = dict->getKey(i);
        PdfRefList* refList = (PdfRefList*) g_hash_table_lookup(this->refListsOther,
                              cDictName);
        if (!refList)
        {
            char* indexName = NULL;
            if (strcmp(cDictName, "Font") == 0)
            {
                indexName = g_strdup("F");
            }
            else if (strcmp(cDictName, "XObject") == 0)
            {
                indexName = g_strdup("I");
            }
            else if (strcmp(cDictName, "ExtGState") == 0)
            {
                indexName = g_strdup("Gs");
            }
            else if (strcmp(cDictName, "Pattern") == 0)
            {
                indexName = g_strdup("p");
            }
            else
            {
                indexName = g_strdup_printf("o%i-", otherObjectId++);
            }

            refList = new PdfRefList(this->xref, this->objectWriter, this->writer,
                                     indexName);
            char* dictName = g_strdup(dict->getKey(i));

            // insert the new RefList into the hash table
            g_hash_table_insert(this->refListsOther, dictName, refList);
        }

        refList->parse(dict, i, doc, replacementList);

    }

    Object* o = new Object();
    page->getContents(o);

    if (o->getType() == objStream)
    {
        Dict* dict = o->getStream()->getDict();

        Object filter;
        dict->lookup("Filter", &filter);
        //			// this may would be better, but not working...:-/
        //			Object oDict;
        //			oDict.initDict(dict);
        //			Stream * txtStream = stream->addFilters(oDict);
        //			writePlainStream(txtStream);

        if (filter.isNull())
        {
            writePlainStream(o->getStream(), replacementList);
        }
        else if (filter.isName("FlateDecode"))
        {
            writeGzStream(o->getStream(), replacementList);
        }
        else if (filter.isName())
        {
            g_warning("Unhandled stream filter: %s\n", filter.getName());
        }
    }
    else
    {
        g_warning("other poppler type: %i\n", o->getType());
    }

    for (GList* l = replacementList; l != NULL; l = l->next)
    {
        RefReplacement* f = (RefReplacement*) l->data;
        delete f;
    }
    g_list_free(replacementList);

    o->free();
    delete o;
    this->resources = NULL;

    return true;
}