This commit is contained in:
20
docs/snippets/r/config/element_based_output.md
Normal file
20
docs/snippets/r/config/element_based_output.md
Normal file
@@ -0,0 +1,20 @@
|
||||
```r title="R"
|
||||
library(kreuzberg)
|
||||
|
||||
config <- list(
|
||||
result_format = "element_based",
|
||||
output_format = "markdown"
|
||||
)
|
||||
|
||||
json <- extract_file_sync("document.pdf", "application/pdf", config)
|
||||
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
|
||||
|
||||
cat(sprintf("Total elements: %d\n\n", length(result$elements)))
|
||||
|
||||
for (i in seq_along(result$elements)) {
|
||||
element <- result$elements[[i]]
|
||||
cat(sprintf("Element %d:\n", i))
|
||||
cat(sprintf(" Type: %s\n", element$element_type))
|
||||
cat(sprintf(" Content: %s\n\n", substr(element$content, 1, 100)))
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user