1

I'm trying to automate the conversion of Autocad DXF to SVG files and found out that Inkscape CLI can be used for this purpose.

The command I'm using is:

inkscape -z -l output.svg -f input.dxf

-z: without gui | -l: export plain SVG | -f: input file

When I run this command on Ubuntu 18.04, the conversion succeeds, however, when I run this command inside a docker container (derived from Alpine + RUN apk --no-cache add inkscape), I get the following error:

input.dxf:1: parser error : Start tag expected, '<' not found 0 ^

** (inkscape:18): WARNING **: Specified document input.dxf cannot be opened (does not exist or not a valid SVG file)

It looks like Inkscape is trying to open the DXF file as an SVG file and fails because it expects XML like input (DXF files do not contain XML-like tags).

I tried to convert it to a PDF by using:

inkscape -z -A output.pdf -f input.dxf

-z: without gui | -A: export PDF | -f: input file

But the error is exactly the same.

Does anyone have an idea how I can further debug this scenario?

Update

I also have to mention that I'm disabling the DXF import dialog by modifying the file dxf_input.inx by removing the <param /> block.

huysentruitw
  • 27,376
  • 9
  • 90
  • 133

1 Answers1

0

What's your Inkscape version?

When I try to import a dxf file via command line, I get a graphical user inface dialog that asks me about import parameters. Suppressing the GUI does not work here. This requires a GUI.

The -z parameter does not work here, and is (seems to be) ignored (this is with Inkscape 0.92.x, the stable development branch). The dialog opens, I click OK, then the output file is being created.

I don't think this is going to work as you intend it to work.

Option 1:

There is a script, dxf2svg, which seems to be available from multiple sources on sourceforge and github, which will probably be more useful here.

Option 2:

Or you can use the Inkscape extension that does the dxf import directly:

Convert DXF to SVG in Inkscape CLI while keeping layers

It seems to use the default parameters for the dialog, so you may need to tweak them a little to adapt to your drawings.

Moini
  • 1,239
  • 9
  • 10