forked from 1b-agent/opencadstudio-upstream
PDFIMPORTIMAGEPATH and per-import layer prefixes
- PDFIMPORTIMAGEPATH names the image extraction folder: relative to the PDF's folder (default "PDF Images"), absolute as given, "." for none. - Every import of the session gets the next prefix (PDF_, PDF2_, PDF3_ ...), also when the same file is imported again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
edbbc9d135
commit
72f7ff5cc5
4 files changed
+61
-22
No files matched your search
@@ -134,6 +134,35 @@ pub fn set_import_settings(settings: PdfImportSettings) {
|
||||
}
|
||||
}
|
||||
|
||||
static IMAGE_PATH: std::sync::Mutex<Option<String>> = std::sync::Mutex::new(None);
|
||||
|
||||
/// PDFIMPORTIMAGEPATH: the folder raster images are extracted to — relative
|
||||
/// to the folder of the PDF, absolute as given, empty for that folder itself.
|
||||
pub fn image_path() -> String {
|
||||
IMAGE_PATH
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|p| p.clone())
|
||||
.unwrap_or_else(|| "PDF Images".to_string())
|
||||
}
|
||||
|
||||
pub fn set_image_path(path: String) {
|
||||
if let Ok(mut p) = IMAGE_PATH.lock() {
|
||||
*p = Some(path);
|
||||
}
|
||||
}
|
||||
|
||||
/// The extraction folder for the PDF at `pdf`.
|
||||
pub fn image_dir(pdf: &str) -> Option<std::path::PathBuf> {
|
||||
let setting = image_path();
|
||||
let folder = std::path::Path::new(&setting);
|
||||
if folder.is_absolute() {
|
||||
return Some(folder.to_path_buf());
|
||||
}
|
||||
let parent = std::path::Path::new(pdf).parent()?;
|
||||
Some(if setting.is_empty() { parent.to_path_buf() } else { parent.join(folder) })
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum ImportArea {
|
||||
All,
|
||||
|
||||
Reference in new issue
Block a user