[poppler] Poppler metadata expansion

Leonard Rosenthol leonardr at pdfsages.com
Mon May 9 08:49:48 PDT 2005


At 11:36 AM 5/9/2005, Emil Soleyman-Zomalan wrote:
>I picked up the optimized term, erroneously it seems, from the source
>code of other applications. I will make the change so that optimized
>reads linearized from now on.

         Thanks!


>The reason for treating dates as strings was to do the actual
>reformatting in the application itself (Evince) so that we could provide
>that function to other areas that could possibly require it.

         That makes sense...

         Though it might be nice to have a similar API call inside of 
Poppler for converting PDF dates into some other date format (time_t, 
etc.).  pdfinfo has such a routine (printInfoDate()) from which the 
relevent code can be lifted.

         Or if it helps, here are two snippets from my library that might 
help.  They use std::string, so you may wish to change... (and in looking 
at them now, for the first time in a LONG time - they could certainly be 
cleaned up and more generalized).


Leonard
------------------------------------
int AcroDateTime::AcrobatDateToLocalDate ( const char * inAcrobatDate, char 
* outLocalDate, ASInt32 inBufferLength )
         {
                 tm 
theTimeRecord ;
                 long                                    theYear 
                              = 0 ;
                 long                                    theMonth 
                              = 0 ;
                 long                                    theDay 
                              = 0 ;
                 long                                    theHour 
                              = 0 ;
                 long                                    theMinute 
                              = 0 ;
                 long                                    theSecond 
                              = 0 ;
                 long                                    theReturnLength ;

                 memset( &theTimeRecord, 0, sizeof( theTimeRecord ) ) 
;          // clear the record of spurious data

                 sscanf( inAcrobatDate, "D:%04ld%02ld%02ld%02ld%02ld%02ld", 
&theYear, &theMonth, &theDay, &theHour, &theMinute, &theSecond ) ;

                 theTimeRecord.tm_year           = theYear - 1900 ;      // 
years since 1900
                 theTimeRecord.tm_mon            = theMonth - 1 
;                // 0 - 11
                 theTimeRecord.tm_mday           = theDay ;
                 theTimeRecord.tm_hour           = theHour ;
                 theTimeRecord.tm_min            = theMinute ;
                 theTimeRecord.tm_sec            = theSecond ;

                 theReturnLength = strftime( outLocalDate, inBufferLength, 
"%x %X", &theTimeRecord ) ;

                 return theReturnLength ;

         }       // end AcrobatDateToLocalDate


void AcroDateTime::AcrobatDateToISO8601( const std::string& inTimeStr, 
std::string& outTimeStr )
{
         tm              theTimeRecord ;
         long    theYear                                         = 0 ;
         long    theMonth                                        = 0 ;
         long    theDay                                          = 0 ;
         long    theHour                                         = 0 ;
         long    theMinute                                       = 0 ;
         long    theSecond                                       = 0 ;
         long    theReturnLength ;

         memset( &theTimeRecord, 0, sizeof( theTimeRecord ) ) ;          // 
clear the record of spurious data

         sscanf( inTimeStr.c_str(), "D:%04ld%02ld%02ld%02ld%02ld%02ld",
                                                         &theYear, 
&theMonth, &theDay, &theHour, &theMinute, &theSecond ) ;

         theTimeRecord.tm_year           = theYear - 1900 ;              // 
years since 1900
         theTimeRecord.tm_mon            = theMonth - 1 ;                // 
0 - 11
         theTimeRecord.tm_mday           = theDay ;
         theTimeRecord.tm_hour           = theHour ;
         theTimeRecord.tm_min            = theMinute ;
         theTimeRecord.tm_sec            = theSecond ;

         char    buf[1024];
         theReturnLength = strftime( buf, 1024, "%Y-%m-%dT%H:%M:%S", 
&theTimeRecord ) ;

         outTimeStr.assign( buf );
}


---------------------------------------------------------------------------
Leonard Rosenthol                            <mailto:leonardr at pdfsages.com>
Chief Technical Officer                      <http://www.pdfsages.com>
PDF Sages, Inc.                              215-938-7080 (voice)
                                              215-938-0880 (fax)




More information about the poppler mailing list