-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev #224
Changes from all commits
13feb49
b75f505
cc69626
11a9199
7beb21e
b481a2e
ed87e7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ members = [ | |
| "packages/ducsvg/src/pdf2svg", | ||
| ] | ||
|
|
||
|
|
||
| [profile.release] | ||
| lto = true | ||
| opt-level = "s" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,16 +11,27 @@ mod integration_tests { | |
| use hipdf::fonts::{Font, StandardFont}; | ||
|
|
||
| fn get_assets_dir() -> String { | ||
| // Use environment variable if set, otherwise use relative path | ||
| if let Ok(path) = std::env::var("DUC_ASSETS_DIR") { | ||
| path | ||
| } else { | ||
| // Rust tests run from the crate directory, so we need to adjust the path | ||
| let current_dir = std::env::current_dir().unwrap(); | ||
| let assets_path = current_dir.join("../../../../assets/testing/duc-files"); | ||
| assets_path.to_string_lossy().to_string() | ||
| } | ||
| } | ||
|
|
||
| fn list_duc_files() -> Vec<String> { | ||
| let dir = get_assets_dir(); | ||
| let mut files: Vec<String> = std::fs::read_dir(&dir) | ||
| .unwrap_or_else(|e| panic!("read assets dir {dir}: {e}")) | ||
| .filter_map(|e| e.ok()) | ||
| .map(|e| e.file_name().to_string_lossy().to_string()) | ||
| .filter(|name| name.ends_with(".duc")) | ||
| .collect(); | ||
| files.sort(); | ||
| files | ||
| } | ||
|
|
||
| /// Load a DUC file from the assets directory | ||
| fn load_duc_file(filename: &str) -> Vec<u8> { | ||
| let assets_dir = get_assets_dir(); | ||
|
|
@@ -512,6 +523,33 @@ mod integration_tests { | |
|
|
||
| println!("🔧 Real data scaling tests completed"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_plot_all_assets() { | ||
| for file in list_duc_files() { | ||
| let duc_data = load_duc_file(&file); | ||
|
|
||
| let options = ConversionOptions { | ||
| scale: None, | ||
| mode: ConversionMode::Plot, | ||
| metadata_title: Some(file.clone()), | ||
| metadata_author: Some("DUC2PDF Test Suite".to_string()), | ||
| metadata_subject: Some("Asset plot conversion".to_string()), | ||
| background_color: Some("transparent".to_string()), | ||
| }; | ||
|
|
||
| match convert_duc_to_pdf_with_options(&duc_data, options) { | ||
| Ok(pdf_bytes) => { | ||
| validate_pdf_structure(&pdf_bytes, Path::new(&format!("memory:{file}"))); | ||
| println!("✅ {file}: plot OK, {} bytes", pdf_bytes.len()); | ||
| } | ||
| Err(e) => { | ||
| println!("⚠️ {file}: plot failed: {e}"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+527
to
+551
|
||
|
|
||
| use duc::types::{ | ||
| ELEMENT_CONTENT_PREFERENCE, STROKE_CAP, STROKE_JOIN, STROKE_PREFERENCE, | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image/webpis now detected asResourceType::WebPand routed throughprocess_image_file(), butcreate_image_xobject()currently only supportsPngandJpegand returns an error for other variants. This means WebP resources will fail to process at runtime if they go throughResourceStreamer. Either add WebP support in the image embedding path, or don’t classifyimage/webpas a supported image type here until it’s implemented end-to-end.