@@ -21,6 +21,9 @@ namespace pdflib
2121 nlohmann::json get ();
2222
2323 int get_number_of_pages () { return number_of_pages; }
24+
25+ nlohmann::json get_annotations () { return json_annots; }
26+ nlohmann::json get_table_of_contents () { return json_annots[" table_of_contents" ]; }
2427
2528 bool process_document_from_file (std::string& _filename);
2629 bool process_document_from_bytesio (std::string& _buffer);
@@ -47,6 +50,8 @@ namespace pdflib
4750
4851 int number_of_pages;
4952
53+ // nlohmann::json json_toc; // table-of-contents
54+ nlohmann::json json_annots;
5055 nlohmann::json json_document;
5156 };
5257
@@ -56,15 +61,15 @@ namespace pdflib
5661
5762 timings({}),
5863 qpdf_document(),
59-
60- // qpdf_root(NULL),
61- // qpdf_pages(NULL),
6264
6365 // have compatibulity between QPDF v10 and v11
6466 qpdf_root(),
6567 qpdf_pages(),
6668
6769 number_of_pages(-1 ),
70+
71+ // json_toc(nlohmann::json::value_t::null),
72+ json_annots(nlohmann::json::value_t ::null),
6873 json_document(nlohmann::json::value_t ::null)
6974 {}
7075
@@ -75,14 +80,14 @@ namespace pdflib
7580 timings(timings_),
7681 qpdf_document(),
7782
78- // qpdf_root(NULL),
79- // qpdf_pages(NULL),
80-
8183 // have compatibulity between QPDF v10 and v11
8284 qpdf_root(),
8385 qpdf_pages(),
8486
8587 number_of_pages(-1 ),
88+
89+ // json_toc(nlohmann::json::value_t::null),
90+ json_annots(nlohmann::json::value_t ::null),
8691 json_document(nlohmann::json::value_t ::null)
8792 {}
8893
@@ -91,6 +96,11 @@ namespace pdflib
9196
9297 nlohmann::json pdf_decoder<DOCUMENT>::get()
9398 {
99+ {
100+ // json_document["table_of_contents"] = json_toc;
101+ json_document[" annotations" ] = json_annots;
102+ }
103+
94104 {
95105 nlohmann::json& timings_ = json_document[" timings" ];
96106
@@ -118,6 +128,9 @@ namespace pdflib
118128 qpdf_root = qpdf_document.getRoot ();
119129 qpdf_pages = qpdf_root.getKey (" /Pages" );
120130
131+ // json_toc = extract_toc_in_json(qpdf_root);
132+ json_annots = extract_document_annotations_in_json (qpdf_document, qpdf_root);
133+
121134 number_of_pages = qpdf_pages.getKey (" /Count" ).getIntValue ();
122135 LOG_S (INFO) << " #-pages: " << number_of_pages;
123136
@@ -148,13 +161,17 @@ namespace pdflib
148161 try
149162 {
150163 std::string description = " processing buffer" ;
151- qpdf_document.processMemoryFile (description.c_str (), buffer.c_str (), buffer.size ());
164+ qpdf_document.processMemoryFile (description.c_str (),
165+ buffer.c_str (), buffer.size ());
152166
153167 LOG_S (INFO) << " buffer processed by qpdf!" ;
154168
155169 qpdf_root = qpdf_document.getRoot ();
156170 qpdf_pages = qpdf_root.getKey (" /Pages" );
157171
172+ // json_toc = extract_toc_in_json(qpdf_root);
173+ json_annots = extract_document_annotations_in_json (qpdf_document, qpdf_root);
174+
158175 number_of_pages = qpdf_pages.getKey (" /Count" ).getIntValue ();
159176 LOG_S (INFO) << " #-pages: " << number_of_pages;
160177
@@ -253,7 +270,8 @@ namespace pdflib
253270 timings[__FUNCTION__] = timer.get_time ();
254271 }
255272
256- void pdf_decoder<DOCUMENT>::update_timings(std::map<std::string, double >& timings_, bool set_timer)
273+ void pdf_decoder<DOCUMENT>::update_timings(std::map<std::string, double >& timings_,
274+ bool set_timer)
257275 {
258276 for (auto itr=timings_.begin (); itr!=timings_.end (); itr++)
259277 {
0 commit comments