Skip to content

Import PDF and Adobe Illustrator files directly - #429

Closed
mcmartnor wants to merge 3 commits into
inkcut:masterfrom
mcmartnor:feature/pdf-import
Closed

mcmartnor wants to merge 3 commits into
inkcut:masterfrom
mcmartnor:feature/pdf-import

Conversation

@mcmartnor

@mcmartnor mcmartnor commented Aug 19, 2026 •

Copy link
Copy Markdown

Depends on #427 — this branch uses defer_to_thread from inkcut/core/utils.py, which #427 adds. Happy to rebase within a day of #427 landing, or to fold it in if you'd rather review one branch.

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.

  • Converters (job/importers.py): poppler's pdftocairo (Inkscape fallback) converts page 1 to SVG on open, with a content-hash cache, unique atomic temp files, and a visible multi-page warning (via pdfinfo).
  • Integration: conversion runs off the GUI thread (defer_to_thread from 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 a source_document so 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 on defer_to_thread from #427.

Testing

Verified by daily use importing .ai and .pdf files 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

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.
@frmdstryr

Copy link
Copy Markdown
Collaborator

I have no interest in supporting anything other than svg.

@frmdstryr frmdstryr closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants