static void print_embedded_files(poppler::document *doc) { std::cout << "Document embedded files:" << std::endl; std::vector<poppler::embedded_file *> ef = doc->embedded_files(); if (!ef.empty()) { std::vector<poppler::embedded_file *>::const_iterator it = ef.begin(), it_end = ef.end(); const std::ios_base::fmtflags f = std::cout.flags(); std::left(std::cout); for (; it != it_end; ++it) { poppler::embedded_file *f = *it; std::cout << " " << std::setw(out_width + 10) << f->name() << " " << std::setw(10) << out_size(f->size()) << " " << std::setw(20) << out_date(f->creation_date()) << " " << std::setw(20) << out_date(f->modification_date()) << std::endl << " "; if (f->description().empty()) { std::cout << "<no description>"; } else { std::cout << f->description(); } std::cout << std::endl << " " << std::setw(35) << (f->checksum().empty() ? std::string("<no checksum>") : out_hex_string(f->checksum())) << " " << (f->mime_type().empty() ? std::string("<no mime type>") : f->mime_type()) << std::endl; } std::cout.flags(f); } else { std::cout << "<no embedded files>" << std::endl; } std::cout << std::endl; }
// //////////////////////////////////////////////////////////////////////////// TimeVal TimeVal::FromString(const char *in_date) { TimeVal out_date(0, 0); time_t tv_sec; // Because it's OS-specific sizeof(time_t) != sizeof(long) ParseFromString(in_date, tv_sec, out_date.tv_usec, 6); out_date.tv_sec = static_cast<long>(tv_sec); return(out_date); }
static void print_info(poppler::document *doc) { std::cout << "Document information:" << std::endl; int major = 0, minor = 0; doc->get_pdf_version(&major, &minor); std::cout << std::setw(out_width) << "PDF version" << ": " << major << "." << minor << std::endl; std::string permanent_id, update_id; if (doc->get_pdf_id(&permanent_id, &update_id)) { std::cout << std::setw(out_width) << "PDF IDs" << ": P: " << permanent_id << " - U: " << update_id << std::endl; } else { std::cout << std::setw(out_width) << "PDF IDs" << ": <none>" << std::endl; } const std::vector<std::string> keys = doc->info_keys(); std::vector<std::string>::const_iterator key_it = keys.begin(), key_end = keys.end(); for (; key_it != key_end; ++key_it) { std::cout << std::setw(out_width) << *key_it << ": " << doc->info_key(*key_it) << std::endl; } std::cout << std::setw(out_width) << "Date (creation)" << ": " << out_date(doc->info_date("CreationDate")) << std::endl; std::cout << std::setw(out_width) << "Date (modification)" << ": " << out_date(doc->info_date("ModDate")) << std::endl; std::cout << std::setw(out_width) << "Number of pages" << ": " << doc->pages() << std::endl; std::cout << std::setw(out_width) << "Linearized" << ": " << doc->is_linearized() << std::endl; std::cout << std::setw(out_width) << "Encrypted" << ": " << doc->is_encrypted() << std::endl; std::cout << std::endl; }
const Date History::start_date() const { Date out_date(DateUtils::date_min()); if(!_history.empty() && !_in_waiting.empty()) { out_date = (_history.front().date() < _in_waiting.front().date())?_history.front().date():_in_waiting.front().date(); }else if(!_history.empty()) { out_date = _history.front().date(); }else if(!_in_waiting.empty()) { out_date = _in_waiting.front().date(); } return out_date; }
const Date History::end_date() const { // if(_history.empty())compta_error(); Date out_date(DateUtils::date_min()); if(!_history.empty() && !_in_waiting.empty()) { out_date = (_history.back().date() > _in_waiting.back().date())?_history.back().date():_in_waiting.back().date(); }else if(!_history.empty()) { out_date = _history.back().date(); }else if(!_in_waiting.empty()) { out_date = _in_waiting.back().date(); } return out_date; }
/* generate data qc page -----------------------------------------------------*/ static int gen_page3(gtime_t time, const char *temp, const char *page) { FILE *ifp,*ofp; gtime_t ts,te; double ep[6],hour[24],mp1[MAXSTA][24]= {{0}},mp2[MAXSTA][24]= {{0}}; double slip[MAXSTA][24]= {{0}},val1[MAXSTA],val2[MAXSTA],val3[MAXSTA]; char buff[1024],file[1024],*sta[MAXSTA],str[MAXSTA][32]; int i,j,n,nsta=0,sec=0; ts=timeadd(time,-90000.0); te=timeadd(time, -3600.0); for (i=0; i<MAXSTA; i++) sta[i]=str[i]; for (i=0; i<24; i++) { time2epoch(timeadd(ts,i*3600.0),ep); sprintf(file,QC_FILE,ep[0],ep[1],ep[2],ep[3]); if (!(n=read_qc(file,sta,val1,val2,val3))) continue; for (j=0; j<n; j++) { mp1 [j][i]=val1[j]; mp2 [j][i]=val2[j]; slip[j][i]=val3[j]; } hour[i]=ep[3]; nsta=n; } if (!(ifp=fopen(temp,"r"))) { fprintf(stderr,"file open error: %s\n",temp); return 0; } if (!(ofp=fopen(page,"w"))) { fprintf(stderr,"file open error: %s\n",page); fclose(ifp); return 0; } while (fgets(buff,sizeof(buff),ifp)) { if (strstr(buff,"@DATE START" )) sec=1; else if (strstr(buff,"@TABLE0 START")) sec=2; else if (strstr(buff,"@TABLE1 START")) sec=3; else if (strstr(buff,"@TABLE2 START")) sec=4; else if (strstr(buff,"@DATE END" )) sec=0; else if (strstr(buff,"@TABLE0 END" )) sec=0; else if (strstr(buff,"@TABLE1 END" )) sec=0; else if (strstr(buff,"@TABLE2 END" )) sec=0; switch (sec) { case 0: fputs(buff,ofp); break; case 1: out_date(ofp,ts,te); break; case 2: out_table1(ofp,sta,nsta,hour,mp1 ,3); break; case 3: out_table1(ofp,sta,nsta,hour,mp2 ,3); break; case 4: out_table1(ofp,sta,nsta,hour,slip,0); break; } } fclose(ifp); fclose(ofp); return 1; }