-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6940d39
commit c64fcbb
Showing
6 changed files
with
87 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"default-plugins":{"identifier":"default-plugins","description":"enables the default permissions","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","sql:allow-load","sql:allow-select","sql:allow-close","sql:allow-execute","shell:allow-open","dialog:allow-open","os:allow-platform","http:allow-fetch",{"identifier":"http:default","allow":[{"url":"https://epzrdxofotzufykimwuc.supabase.co/functions/v1/update-checker/pOwtY_2gz3GHtISkVIv6Pg"},{"url":"https://admin-console.kine-helper.be/api/*"}]},"fs:allow-applocaldata-read","fs:allow-applocaldata-read-recursive","fs:allow-applocaldata-write","fs:allow-applocaldata-write-recursive","fs:allow-applocaldata-meta","fs:allow-applocaldata-meta-recursive","fs:allow-remove","fs:allow-create","fs:allow-exists","fs:allow-app-write","fs:allow-app-write-recursive","fs:allow-appcache-write","fs:allow-appcache-write-recursive","fs:allow-appconfig-write","fs:allow-app-read","fs:allow-app-read-recursive","fs:allow-appcache-read","fs:allow-appcache-read-recursive","fs:allow-appconfig-read","updater:allow-check","updater:default","dialog:allow-save","process:allow-restart"],"platforms":["macOS","linux","android","iOS"]},"default-plugins-windows":{"identifier":"default-plugins-windows","description":"add the fs dir document permissions for windows","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:path:allow-resolve-directory","sql:allow-load","sql:allow-select","sql:allow-close","sql:allow-execute","shell:allow-open","dialog:allow-open","os:allow-platform","http:allow-fetch",{"identifier":"http:default","allow":[{"url":"https://epzrdxofotzufykimwuc.supabase.co/functions/v1/update-checker/pOwtY_2gz3GHtISkVIv6Pg"},{"url":"https://admin-console.kine-helper.be/api/*"}]},"fs:allow-applocaldata-read","fs:allow-applocaldata-read-recursive","fs:allow-applocaldata-write","fs:allow-applocaldata-write-recursive","fs:allow-applocaldata-meta","fs:allow-applocaldata-meta-recursive","fs:allow-document-read","fs:allow-document-read-recursive","fs:allow-document-write","fs:allow-document-write-recursive","fs:allow-document-meta","fs:allow-document-meta-recursive","fs:allow-remove","fs:allow-create","fs:allow-exists","fs:allow-app-write","fs:allow-app-write-recursive","fs:allow-appcache-write","fs:allow-appcache-write-recursive","fs:allow-appconfig-write","fs:allow-app-read","fs:allow-app-read-recursive","fs:allow-appcache-read","fs:allow-appcache-read-recursive","fs:allow-appconfig-read","updater:allow-check","updater:default","dialog:allow-save","process:allow-restart"],"platforms":["windows"]}} | ||
{"default-plugins":{"identifier":"default-plugins","description":"enables the default permissions","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","sql:allow-load","sql:allow-select","sql:allow-close","sql:allow-execute","shell:allow-open",{"identifier":"shell:allow-execute","allow":[{"args":["-d",{"validator":"^[a-zA-Z0-9_\\-]{3,20}$"},{"validator":"^/.+?/temp_print_file\\.prn$"}],"cmd":"lp","name":"lp","sidecar":false}]},"dialog:allow-open","os:allow-platform","http:allow-fetch",{"identifier":"http:default","allow":[{"url":"https://epzrdxofotzufykimwuc.supabase.co/functions/v1/update-checker/pOwtY_2gz3GHtISkVIv6Pg"},{"url":"https://admin-console.kine-helper.be/api/*"}]},"fs:allow-applocaldata-read","fs:allow-applocaldata-read-recursive","fs:allow-applocaldata-write","fs:allow-applocaldata-write-recursive","fs:allow-applocaldata-meta","fs:allow-applocaldata-meta-recursive","fs:allow-remove","fs:allow-create","fs:allow-exists","fs:allow-app-write","fs:allow-app-write-recursive","fs:allow-appcache-write","fs:allow-appcache-write-recursive","fs:allow-appconfig-write","fs:allow-app-read","fs:allow-app-read-recursive","fs:allow-appcache-read","fs:allow-appcache-read-recursive","fs:allow-appconfig-read","updater:allow-check","updater:default","dialog:allow-save","process:allow-restart"],"platforms":["macOS","linux","android","iOS"]},"default-plugins-windows":{"identifier":"default-plugins-windows","description":"add the fs dir document permissions for windows","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:path:allow-resolve-directory","sql:allow-load","sql:allow-select","sql:allow-close","sql:allow-execute","shell:allow-open","dialog:allow-open","os:allow-platform","http:allow-fetch",{"identifier":"http:default","allow":[{"url":"https://epzrdxofotzufykimwuc.supabase.co/functions/v1/update-checker/pOwtY_2gz3GHtISkVIv6Pg"},{"url":"https://admin-console.kine-helper.be/api/*"}]},"fs:allow-applocaldata-read","fs:allow-applocaldata-read-recursive","fs:allow-applocaldata-write","fs:allow-applocaldata-write-recursive","fs:allow-applocaldata-meta","fs:allow-applocaldata-meta-recursive","fs:allow-document-read","fs:allow-document-read-recursive","fs:allow-document-write","fs:allow-document-write-recursive","fs:allow-document-meta","fs:allow-document-meta-recursive","fs:allow-remove","fs:allow-create","fs:allow-exists","fs:allow-app-write","fs:allow-app-write-recursive","fs:allow-appcache-write","fs:allow-appcache-write-recursive","fs:allow-appconfig-write","fs:allow-app-read","fs:allow-app-read-recursive","fs:allow-appcache-read","fs:allow-appcache-read-recursive","fs:allow-appconfig-read","updater:allow-check","updater:default","dialog:allow-save","process:allow-restart"],"platforms":["windows"]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
use crate::printer::{escp::build_document, form_data_modeling::DocumentFormData}; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::Path; | ||
use std::process::Command; | ||
// use std::fs::File; | ||
// use std::io::Write; | ||
// use std::path::Path; | ||
// use std::process::Command; | ||
|
||
#[tauri::command] | ||
pub fn print_attestation(printer_name: String, form_data: DocumentFormData) -> String { | ||
pub fn print_attestation(printer_name: String, form_data: DocumentFormData) -> Vec<u8> { | ||
// Create a file with raw ESC/P commands | ||
let file_path = Path::new("temp_print_file.prn"); | ||
let mut file = File::create(&file_path).expect("Failed to create file"); | ||
// for line in build_document(form_data) { | ||
// write!(file, "{}", line).expect("Failed to write to file"); | ||
// } | ||
let doc_bytes = build_document(form_data); | ||
file.write_all(&doc_bytes).expect("Failed to write to file"); | ||
// Construct the lp command | ||
let output = Command::new("lp") | ||
.arg("-d") | ||
.arg(printer_name) | ||
.arg(file_path.to_str().unwrap()) | ||
.output() | ||
.expect("Failed to execute command"); | ||
// let file_path = Path::new("temp_print_file.prn"); | ||
// let mut file = File::create(&file_path).expect("Failed to create file"); | ||
|
||
build_document(form_data) | ||
// file.write_all(&doc_bytes).expect("Failed to write to file"); | ||
// // Construct the lp command | ||
// let output = Command::new("lp") | ||
// .arg("-d") | ||
// .arg(printer_name) | ||
// .arg(file_path.to_str().unwrap()) | ||
// .output() | ||
// .expect("Failed to execute command"); | ||
|
||
if output.status.success() { | ||
println!("Print job sent successfully."); | ||
} else { | ||
eprintln!("Error: {}", String::from_utf8_lossy(&output.stderr)); | ||
} | ||
// if output.status.success() { | ||
// println!("Print job sent successfully."); | ||
// } else { | ||
// eprintln!("Error: {}", String::from_utf8_lossy(&output.stderr)); | ||
// } | ||
|
||
// Clean up | ||
std::fs::remove_file(file_path).expect("Failed to remove temporary file"); | ||
"true".into() | ||
// // Clean up | ||
// std::fs::remove_file(file_path).expect("Failed to remove temporary file"); | ||
// "true".into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters