MCPcopy Create free account
hub / github.com/docling-project/docling-parse / PYBIND11_MODULE

Function PYBIND11_MODULE

app/pybind_parse.cpp:305–1267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305PYBIND11_MODULE(pdf_parsers, m) {
306
307 // ============= Decode Page Config =============
308
309 pybind11::class_<pdflib::decode_config>(m, "DecodePageConfig",
310 R"(
311 Configuration parameters for page decoding.
312
313 Attributes:
314 page_boundary (str): The page boundary specification [choices: crop_box, media_box].
315 do_sanitization (bool): Sanitize the chars into lines [default=true].
316 keep_char_cells (bool): Expose individual char cells in the decoded output. Internal base text cells are still built when words or lines are requested [default=true].
317 keep_shapes (bool): Keep all the graphic shapes [default=true].
318 keep_bitmaps (bool): Keep all the bitmap resources [default=true].
319 max_num_lines (int): Maximum number of lines to keep (-1 means no cap) [default=-1].
320 max_num_bitmaps (int): Maximum number of bitmaps to keep (-1 means no cap) [default=-1].
321 min_visible_clip_extent (float): Minimum clip width/height treated as a usable image clip [default=1e-3].
322 keep_glyphs (bool): If true, keep GLYPH<...> fallback strings in output; if false, replace them with a space [default=false].
323 keep_qpdf_warnings (bool): If true, QPDF warnings are emitted; if false, they are suppressed [default=false].
324 )")
325 .def(pybind11::init<>())
326 .def_readwrite("page_boundary", &pdflib::decode_config::page_boundary)
327 .def_readwrite("do_sanitization", &pdflib::decode_config::do_sanitization)
328 .def_readwrite("keep_char_cells", &pdflib::decode_config::keep_char_cells)
329 .def_readwrite("keep_shapes", &pdflib::decode_config::keep_shapes)
330 .def_readwrite("keep_bitmaps", &pdflib::decode_config::keep_bitmaps)
331 .def_readwrite("max_num_lines", &pdflib::decode_config::max_num_lines)
332 .def_readwrite("max_num_bitmaps", &pdflib::decode_config::max_num_bitmaps)
333 .def_readwrite("min_visible_clip_extent", &pdflib::decode_config::min_visible_clip_extent)
334 .def_readwrite("create_word_cells", &pdflib::decode_config::create_word_cells)
335 .def_readwrite("create_line_cells", &pdflib::decode_config::create_line_cells)
336 .def_readwrite("enforce_same_font", &pdflib::decode_config::enforce_same_font)
337 .def_readwrite("horizontal_cell_tolerance", &pdflib::decode_config::horizontal_cell_tolerance)
338 .def_readwrite("word_space_width_factor_for_merge", &pdflib::decode_config::word_space_width_factor_for_merge)
339 .def_readwrite("line_space_width_factor_for_merge", &pdflib::decode_config::line_space_width_factor_for_merge)
340 .def_readwrite("line_space_width_factor_for_merge_with_space", &pdflib::decode_config::line_space_width_factor_for_merge_with_space)
341 .def_readwrite("do_thread_safe", &pdflib::decode_config::do_thread_safe)
342 .def_readwrite("release_native_memory_every_n_pages", &pdflib::decode_config::release_native_memory_every_n_pages)
343 .def_readwrite("keep_glyphs", &pdflib::decode_config::keep_glyphs)
344 .def_readwrite("keep_qpdf_warnings", &pdflib::decode_config::keep_qpdf_warnings)
345 .def_readwrite("extract_font_programs", &pdflib::decode_config::extract_font_programs)
346 .def("__copy__", [](const pdflib::decode_config& self) { return self; })
347 .def("__deepcopy__", [](const pdflib::decode_config& self, pybind11::dict) { return self; });
348
349 // ============= Typed Resource Bindings (for zero-copy access) =============
350
351 // PdfCell - individual text cell with bounding box and text content
352 pybind11::class_<pdflib::page_item<pdflib::PAGE_CELL>>(m, "PdfCell")
353 .def_readonly("x0", &pdflib::page_item<pdflib::PAGE_CELL>::x0)
354 .def_readonly("y0", &pdflib::page_item<pdflib::PAGE_CELL>::y0)
355 .def_readonly("x1", &pdflib::page_item<pdflib::PAGE_CELL>::x1)
356 .def_readonly("y1", &pdflib::page_item<pdflib::PAGE_CELL>::y1)
357 .def_readonly("r_x0", &pdflib::page_item<pdflib::PAGE_CELL>::r_x0)
358 .def_readonly("r_y0", &pdflib::page_item<pdflib::PAGE_CELL>::r_y0)
359 .def_readonly("r_x1", &pdflib::page_item<pdflib::PAGE_CELL>::r_x1)
360 .def_readonly("r_y1", &pdflib::page_item<pdflib::PAGE_CELL>::r_y1)
361 .def_readonly("r_x2", &pdflib::page_item<pdflib::PAGE_CELL>::r_x2)
362 .def_readonly("r_y2", &pdflib::page_item<pdflib::PAGE_CELL>::r_y2)

Callers

nothing calls this directly

Calls 15

decode_configClass · 0.85
render_configClass · 0.85
get_image_as_bytesMethod · 0.80
to_sum_mapMethod · 0.80
get_canvasMethod · 0.80
unload_document_pageMethod · 0.80
unload_all_documentsMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected