| 124 | } |
| 125 | |
| 126 | void parser::execute_parse(pdflib::decode_config page_config) |
| 127 | { |
| 128 | // initialise the fonts |
| 129 | /* |
| 130 | { |
| 131 | utils::timer timer; |
| 132 | |
| 133 | assert(input_file.count("data")==1); |
| 134 | pdflib::pdf_resource<pdflib::PAGE_FONT>::initialise(input_file["data"], |
| 135 | timings); |
| 136 | |
| 137 | timings["fonts-initialisation"] = timer.get_time(); |
| 138 | } |
| 139 | */ |
| 140 | initialise(input_file["data"]); |
| 141 | |
| 142 | // iterate over the files |
| 143 | nlohmann::json files = input_file["files"]; |
| 144 | for(auto& pair : files.items()) |
| 145 | { |
| 146 | LOG_S(INFO) << pair.key() << " : " << pair.value(); |
| 147 | |
| 148 | nlohmann::json& val = pair.value(); |
| 149 | |
| 150 | std::string inp_filename; |
| 151 | inp_filename = val["filename"]; |
| 152 | |
| 153 | std::string out_filename; |
| 154 | if(val.count("output")==1) |
| 155 | { |
| 156 | out_filename = val["output"]; |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | out_filename = inp_filename+".json"; |
| 161 | } |
| 162 | |
| 163 | std::ifstream ifs(inp_filename); |
| 164 | if(ifs) |
| 165 | { |
| 166 | parse_file(inp_filename, out_filename, val, page_config); |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | LOG_S(ERROR) << "filename: " << inp_filename << " does not exists"; |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | bool parser::parse_input(std::string filename) |
| 176 | { |