This commit is contained in:
21
docs/snippets/r/config/document_structure_config.md
Normal file
21
docs/snippets/r/config/document_structure_config.md
Normal file
@@ -0,0 +1,21 @@
|
||||
```r title="R"
|
||||
library(kreuzberg)
|
||||
|
||||
config <- list(
|
||||
include_document_structure = TRUE,
|
||||
output_format = "markdown"
|
||||
)
|
||||
|
||||
json <- extract_file_sync("document.pdf", "application/pdf", config)
|
||||
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
|
||||
|
||||
cat(sprintf("Total pages: %d\n", length(result$pages)))
|
||||
cat(sprintf("MIME type: %s\n\n", result$mime_type))
|
||||
|
||||
for (i in seq_along(result$pages)) {
|
||||
page <- result$pages[[i]]
|
||||
cat(sprintf("Page %d structure:\n", i))
|
||||
cat(sprintf(" Content: %s\n", substr(page$content, 1, 100)))
|
||||
cat("\n")
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user