Inkscape on OSX cannot open PDF file through terminal command

Asked by Zahir Kelloud

Hi Inkscape community,

First, let me thank you for the time you dedicating to improving Inkscape and helping us users. I am new to using this utility and I'm currently going through a hurdle. My objective is to use inkscape command line to convert PDF files to plain SVG files:

inkscape --without-gui --file=inputfile.pdf --export-plain-svg=outputfile.svg

However I kept getting the following error:

** Message: couldn't open the PDF file.

** (inkscape-bin:25717): WARNING **: Can't open file: inputfile.pdf (doesn't exist)

** (inkscape-bin:25717): WARNING **: Specified document inputfile.pdf cannot be opened (does not exist or not a valid SVG file)

inputfile.pdf does for sure exist and the path to it is correct. Also, the Inkscape GUI can open pdf files but this is not what I want to use.

So, what could possibly be the issue? I'd really appreciate your help on this one.

The following are some details:
I have brewed Inkscape 0.91 r13725 (Jan 28 2015) on my MPB OSX Yosemite from Caskroom/cask/inkscape repo (previously tried the homebrew/x11/inkscape repo). The following is a list of installed dependencies:

(atk, atkmm, bdw-gc, boost, boost-build, cairo, cairomm, cmake, d-bus, fontconfig, freetype, gdk-pixbuf, gettext, git, glib, glibmm, gobject-introspection, graphite2, gsl, gtk+, gtkmm, harfbuzz, hicolor-icon-theme, icu4c, intltool, jasper, jpeg, libatomic_ops, libffi, libpng, libsigc++, libtiff, little-cms, little-cms2, makedepend, mysql, open-mpi, openjpeg, openssl, pango, pangommpixman, pkg-config, poppler, popt, postgresql, python, qt, qt5, readline, sphinx-doc, xz)

Question information

Language:
English Edit question
Status:
Solved
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Solved by:
su_v
Solved:
Last query:
Last reply:
Revision history for this message
Best su_v (suv-lp) said :
#1

On 2016-01-05 21:21 (+0100), Zahir Kelloud wrote:
> I have brewed Inkscape 0.91 r13725 (Jan 28 2015) on my MPB OSX
> Yosemite from Caskroom/cask/inkscape repo

IIUC casks fetch and install a precompiled application bundle (which is provided by the upstream project) as is [1], maybe with a few direct symlinks added here and there by the cask to mimic a regular command line installation. In other words, you attempt to use a GUI application which is not optimized for pure command line usage as such [2]. There are known limitations when using Inkscape.app as pure command line application, among them that _all_ references to files on the command line (input as well as output files) must use absolute paths (otherwise, they are not found). In other words, specify the full path to the PDF file when using the GUI application via command line (for the current directory, you can prepend the variable $PWD (best put in double-quotes to handle and spaces in the path) and a slash '/' to the file name to save some typing if used interactively; for scripts, this should not be a problem).

--
[1] whatever you might have attempted to or successfully (or at least partially successfully) have installed via Homebrew is not related and should not be relevant when using Inkscape.app (I don't use homebrew nor casks myself, so I can't rule out that a parallel homebrew installation might introduce some odd binary conflicts via $PATH and other env variables with Inkscape.app installed as cask - that's for homebrew and cask to deal with (the Inkscape project neither uses homebrew, nor provides official formulas for Inkscape nor any casks.)

[2] The known limitation due to legacy decisions about Inkscape's relocation support when packaged as OS X application bundle is tracked in
* https://bugs.launchpad.net/inkscape/+bug/181639

Revision history for this message
Zahir Kelloud (zahirkelloud) said :
#2

~suv,

You've enlightened me. Thank you so much! Now that I've specified the absolute path to my files, it worked like a charm.

Revision history for this message
Zahir Kelloud (zahirkelloud) said :
#3

Thanks ~suv, that solved my question.

Revision history for this message
Thomas Mansencal (kelsolaar) said :
#4

Hi,

I ended up writing a wrapper that converts the relative paths to absolute paths: https://gist.github.com/KelSolaar/5e24073ffbde03af99d9092580dcf61d

It has been working so far for my use case.

Cheers,

Thomas

Revision history for this message
Mahendra Paipuri (mahendrapaipuri) said :
#5

Hey kelsolaar

I am having this problem right now with using inkscape along with LaTeX in Mac. Unfortunately, I am not really familiar with linux and I am not so sure how to configure your wrapper on my Mac.

Could you please give a step by step instructions for using your wrapper for inkscape?

Thanks

Cheers
Mahendra

Revision history for this message
Thomas Mansencal (kelsolaar) said :
#6

@Mahendra: You need to:

- Download the `inkscape.py` file.
- Put it in a directory, for example `/Users/$USERNAME/bin`.
- Rename it to `inkscape`.
- Make it executable with the terminal:
  - `cd /Users/$USERNAME/bin`
  - `chmod +x inkscape`
- Then finally add `/Users/$USERNAME/bin` to your `$PATH`: https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/#.Uydjga1dXDg

Next time you open a shell, the `inkscape` wrapper should take precedence.