Repository navigation
Conversation
Convert .pdf and PDF-compatible .ai files to SVG on open via poppler's pdftocairo (Inkscape as fallback), with a content-hash cache, unique temp files with atomic replacement, and a multi-page count (via pdfinfo) so callers can warn that only page 1 is imported.
- open_document converts importable files off the UI thread (via defer_to_thread; inline without an event loop) and drops stale conversions when a newer document was opened meanwhile - Job.source_document keeps the file the user opened: the recent list, job history and file dialog show the original path instead of the internal cache name; a multi-page warning is shown in the GUI - can_open accepts .pdf/.ai so drag and drop works; the open dialog filters include vector formats - New documents inherit the previous job's feed settings (they describe the media workflow, not the document) Depends on inkcut.core.utils.defer_to_thread (fix/device-core).
The error raised when neither pdftocairo nor Inkscape is present told every user to run "brew install poppler", which is wrong advice on Linux and Windows. The hint is now chosen from sys.platform. EXTRA_PATHS keeps its macOS-only entries deliberately: they are only consulted after shutil.which() has already failed, so they cost nothing on other platforms. The comment now says so, since it reads like an oversight otherwise.
Collaborator
|
I have no interest in supporting anything other than svg. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #228 asked for EPS or PDF import back in 2020 and has no replies. This covers the PDF half of that request (and .ai files saved with PDF compatibility); EPS is not handled.
Summary
Open PDF and Adobe Illustrator (PDF-compatible
.ai) files directly in Inkcut.job/importers.py): poppler'spdftocairo(Inkscape fallback) converts page 1 to SVG on open, with a content-hash cache, unique atomic temp files, and a visible multi-page warning (viapdfinfo).defer_to_threadfrom Device core: reactor-free thread offload, pre-feed, flush barrier, declared-order defaults #427) with a generation counter so a slow conversion can't replace a newer document; drag-and-drop accepts.pdf/.ai; the job keeps asource_documentso the UI, recent-files menu and job history show the original file instead of an internal cache path.Note:
subprocess.run(capture_output=)makes Python ≥ 3.7 the effective floor for this feature. Depends ondefer_to_threadfrom #427.Testing
Verified by daily use importing
.aiand.pdffiles on macOS. Tests for the conversion and caching paths are not included yet — they need small fixture documents committed to the repo, so say the word if you would rather have them in before this lands.🤖 Generated with Claude Code