From 8323fdd73272a2882781aba3c499ba0be3dff2a6 Mon Sep 17 00:00:00 2001 From: UMTS at Teleco Date: Sat, 13 Dec 2025 02:51:15 +0100 Subject: committing to insanity --- src/core/print/plugins/pdf.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/core/print/plugins/pdf.rs (limited to 'src/core/print/plugins/pdf.rs') diff --git a/src/core/print/plugins/pdf.rs b/src/core/print/plugins/pdf.rs new file mode 100644 index 0000000..2456edb --- /dev/null +++ b/src/core/print/plugins/pdf.rs @@ -0,0 +1,27 @@ +use anyhow::{Context, Result}; +use printpdf::PdfDocumentReference; +use std::fs::File; +use std::io::BufWriter; +use std::path::PathBuf; + +pub struct PdfPlugin; + +impl PdfPlugin { + pub fn new() -> Self { + Self + } + + pub fn export_pdf(&self, doc: PdfDocumentReference, path: &PathBuf) -> Result<()> { + let file = File::create(path).context("Failed to create PDF file for export")?; + let mut writer = BufWriter::new(file); + doc.save(&mut writer) + .context("Failed to save PDF to specified path")?; + Ok(()) + } +} + +impl Default for PdfPlugin { + fn default() -> Self { + Self::new() + } +} -- cgit v1.2.3-70-g09d2