aboutsummaryrefslogtreecommitdiff
path: root/src/core/print/plugins/pdf.rs
diff options
context:
space:
mode:
authorUMTS at Teleco <crt@teleco.ch>2025-12-13 02:51:15 +0100
committerUMTS at Teleco <crt@teleco.ch>2025-12-13 02:51:15 +0100
commit8323fdd73272a2882781aba3c499ba0be3dff2a6 (patch)
treeffbf86473933e69cfaeef30d5c6ea7e5b494856c /src/core/print/plugins/pdf.rs
committing to insanityHEADmaster
Diffstat (limited to 'src/core/print/plugins/pdf.rs')
-rw-r--r--src/core/print/plugins/pdf.rs27
1 files changed, 27 insertions, 0 deletions
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()
+ }
+}