pub fn parse_into_file_with_images(
markdown: String,
output_path: &str,
markdown_path: &Path,
config: ConfigSource<'_>,
font_config: Option<&FontConfig>,
) -> Result<(), MdpError>Expand description
Transforms Markdown content with image support into a styled PDF document and saves it to the specified path.
This is a variant of parse_into_file that supports resolving relative image paths based on the
markdown document location. Remote images can also be downloaded if the fetch feature is enabled.
§Arguments
markdown- The Markdown content to convertoutput_path- The output file path for the generated PDFmarkdown_path- Path to the markdown document (for resolving relative image references)config- Configuration source (Default, File path, or Embedded TOML)font_config- Optional font configuration with custom paths and font overrides
§Returns
Ok(())on successful PDF generation and saveErr(MdpError)if errors occur during parsing, image loading, or file operations
§Example
use std::error::Error;
use markdown2pdf::config::ConfigSource;
use std::path::Path;
fn example() -> Result<(), Box<dyn Error>> {
let markdown = "# Document\n".to_string();
markdown2pdf::parse_into_file_with_images(
markdown,
"output.pdf",
Path::new("document.md"),
ConfigSource::Default,
None
)?;
Ok(())
}