Overview
PDF4LLM’s extraction methods return plain .NET strings — writing them to disk is handled by the standard library. The recommended approach isSystem.IO.File.WriteAllText(), which is straightforward, cross-platform, and available without additional dependencies.
Saving Markdown
Saving JSON
ToJson() returns a JSON string directly — no additional serialisation step is needed:
System.Text.Json:
Saving plain text
Saving per-page chunks
When usingLlamaMarkdownReader, save each page as a separate file using the page number from the chunk metadata to name each file:
Saving with a matching filename
To derive the output filename from the input document automatically:Path.ChangeExtension() swaps the file extension cleanly, keeping the same directory and stem.
Saving to a different directory
To write output to a different folder while keeping the original filename:Processing multiple files
To extract and save output for an entire folder of PDFs:Saving images alongside Markdown
WhenwriteImages: true is used, image files are written to disk automatically during extraction. Create the image directory first, then save the Markdown file alongside it:
Image paths in the Markdown output are relative to wherever the
.md file is opened from. Keep your Markdown file and image directory in the same parent folder to ensure image links resolve correctly.File format summary
Next steps
Extract Markdown
Full walkthrough of ToMarkdown() with all common options.
Extract JSON
Bounding boxes and layout data for custom pipelines.
Extract Text
Plain text extraction and whitespace handling.
Images & Graphics
Controlling image extraction, format, and output path.