[poppler] [PATCH] poppler-qt again

Martin Kretzschmar m_kretzschmar at gmx.net
Wed Apr 6 00:37:06 PDT 2005


Am Dienstag, den 05.04.2005, 18:13 -0400 schrieb Jeff Muizelaar:
> Attached is my cvs candidate for the begining of poppler-qt.
> 
> Changes of Note:
> 	* uses Poppler namespace instead of Poppler prefix
> 	* no more namespace polution with PDFDoc
> 	* renderSlice instead of just render
> 	* nearly verbatim inclusion of some of meta-data functions
> 	  from kpdf and kfile_pdf
> 
> With this patch it should be pretty trivial to convert kfile_pdf to
> poppler-qt.
> 
> -Jeff
> 

Just a little comment wrt. date parsing.

> +
> +/* borrowed from kpdf */
> +QDateTime Document::getDate( const QString & type ) const
> +{
> +    // [Albert] Code adapted from pdfinfo.cc on xpdf
> +    if ( locked )
> +        return QDateTime();
> +
> +    Object info;
> +    data->doc.getDocInfo( &info );
> +    if ( !info.isDict() ) {
> +	info.free();
> +        return QDateTime();
> +    }
> +
> +    Object obj;
> +    char *s;
> +    int year, mon, day, hour, min, sec;
> +    Dict *infoDict = info.getDict();
> +    QString result;
> +
> +    if ( infoDict->lookup( (char*)type.latin1(), &obj )->isString() )
> +    {
> +        s = obj.getString()->getCString();
> +        if ( s[0] == 'D' && s[1] == ':' )
> +            s += 2;
> +
> +        if ( sscanf( s, "%4d%2d%2d%2d%2d%2d", &year, &mon, &day, &hour, &min, &sec ) == 6 )
> +        {
> +            QDate d( year, mon, day );  //CHECK: it was mon-1, Jan->0 (??)
> +            QTime t( hour, min, sec );
> +            if ( d.isValid() && t.isValid() ) {
> +		obj.free();
> +		info.free();
> +		return QDateTime( d, t );
> +	    }
> +        }
> +    }

You could add the Distiller 3 y2k bug workaround from gpdf to this
method.

http://cvs.gnome.org/viewcvs/gpdf/xpdf/pdf-info-dict-util.cc?rev=1.8&view=markup

Ancient Solaris Distillers format years like "19105" Unfortunately I
haven't found the test file I used long ago. But Adobe confirms that
there is a problem:

http://www.adobe.de/aboutadobe/year2000/prodlist.html

> +    obj.free();
> +    info.free();
> +    return QDateTime();
> +}
> +
> +}

Regards,

Martin



More information about the poppler mailing list