mrpiggi / svg

Handling SVG pictures in LaTeX documents using Inkscape, ImageMagick and/or Ghostscript
Other
65 stars 11 forks source link

Inkscape 1.0 support #8

Closed willprice closed 5 years ago

willprice commented 5 years ago

Hi there, Thanks for the very useful package. I've recently switched over to using Inkscape 1.0a1 and I've noticed that they're changed the export CLI interface from having an --export-<filetype> option per filetype to a uniform --export and an --export-type <filetype> flag. Would it be possible to support this new version of inkscape?

Details of CLI after the break

Pre 1.0 inkscape (Inkscape 0.92.4 5da689c313, 2019-01-14)

Usage: inkscape [OPTIONS...] [FILE...]

Available options:
  -V, --version                              Print the Inkscape version number
  -z, --without-gui                          Do not use X server (only process files from console)
  -g, --with-gui                             Try to use X server (even if $DISPLAY is not set)
  -f, --file=FILENAME                        Open specified document(s) (option string may be excluded)
  -p, --print=FILENAME                       Print document(s) to specified output file (use '| program' for pipe)
  -e, --export-png=FILENAME                  Export document to a PNG file
  -d, --export-dpi=DPI                       Resolution for exporting to bitmap and for rasterisation of filters in PS/EPS/PDF (default 96)
  -a, --export-area=x0:y0:x1:y1              Exported area in SVG user units (default is the page; 0,0 is lower-left corner)
  -D, --export-area-drawing                  Exported area is the entire drawing (not page)
  -C, --export-area-page                     Exported area is the entire page
      --export-margin=VALUE                  Sets margin around exported area (default 0) in units of page size for SVG and mm for PS/EPS/PDF
      --export-area-snap                     Snap the bitmap export area outwards to the nearest integer values (in SVG user units)
  -w, --export-width=WIDTH                   The width of exported bitmap in pixels (overrides export-dpi)
  -h, --export-height=HEIGHT                 The height of exported bitmap in pixels (overrides export-dpi)
  -i, --export-id=ID                         The ID of the object to export
  -j, --export-id-only                       Export just the object with export-id, hide all others (only with export-id)
  -t, --export-use-hints                     Use stored filename and DPI hints when exporting (only with export-id)
  -b, --export-background=COLOUR             Background colour of exported bitmap (any SVG-supported colour string)
  -y, --export-background-opacity=VALUE      Background opacity of exported bitmap (either 0.0 to 1.0, or 1 to 255)
  -l, --export-plain-svg=FILENAME            Export document to plain SVG file (no sodipodi or inkscape namespaces)
  -P, --export-ps=FILENAME                   Export document to a PS file
  -E, --export-eps=FILENAME                  Export document to an EPS file
      --export-ps-level=PS Level             Choose the PostScript Level used to export. Possible choices are 2 and 3 (the default)
  -A, --export-pdf=FILENAME                  Export document to a PDF file
      --export-pdf-version=PDF_VERSION       Export PDF to given version. (hint: make sure to input the exact string found in the PDF export
                                             dialogue, e.g. "1.4" which is PDF-a conformant)
      --export-latex                         Export PDF/PS/EPS without text. Besides the PDF/PS/EPS, a LaTeX file is exported, putting the text on
                                             top of the PDF/PS/EPS file. Include the result in LaTeX like: \input{latexfile.tex}
  -M, --export-emf=FILENAME                  Export document to an Enhanced Metafile (EMF) File
  -m, --export-wmf=FILENAME                  Export document to a Windows Metafile (WMF) File
  -T, --export-text-to-path                  Convert text object to paths on export (PS, EPS, PDF, SVG)
      --export-ignore-filters                Render filtered objects without filters, instead of rasterising (PS, EPS, PDF)

Post 1.0 inkscape (Inkscape 1.0alpha (f7d4648084, 2019-03-06, custom)

Usage:
  inkscape [OPTION…]

Help Options:
  -?, --help                                     Show help options
  --help-all                                     Show all help options
  --help-gapplication                            Show GApplication options
  --help-gtk                                     Show GTK+ Options

Application Options:
  -a, --actions=ACTION(:ARG)[;ACTION(:ARG)]*     Actions (with optional arguments), semi-colon separated.
  --action-list                                  Actions: List available actions.
  -V, --version                                  Print: Inkscape version.
  -x, --extension-directory                      Print: Extensions directory.
  --verb-list                                    Print: List verbs.
  -g, --with-gui                                 GUI: With graphical interface.
  -G, --without-gui                              GUI: Console only.
  --batch-process                                GUI: Close window after processing actions (needed as some verbs require GUI).
  --pdf-page=PAGE                                Open: PDF page to import
  --convert-dpi-method=[...]                     Open: Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document].
  --no-convert-text-baseline-spacing             Open: Do not fix pre-0.92 document's text baseline spacing on opening.
  -I, --query-id=OBJECT-ID[,OBJECT-ID]*          Query: ID(s) of object(s) to be queried.
  -S, --query-all                                Query: Print bounding boxes of all objects.
  -X, --query-x                                  Query: X coordinate of drawing or object (if specified by --query-id).
  -Y, --query-y                                  Query: Y coordinate of drawing or object (if specified by --query-id).
  -W, --query-width                              Query: Width of drawing or object (if specified by --query-id).
  -H, --query-height                             Query: Height of drawing or object (if specified by --query-id).
  --vacuum-defs                                  Process: Remove unused definitions from the <defs> section(s) of document.
  --select=OBJECT-ID[,OBJECT-ID]*                Process: Select objects: comma separated list of IDs.
  --verb=VERB-ID[;VERB-ID]*                      Process: Verb(s) to call when Inkscape opens.
  --shell                                        Process: Start Inkscape in interactive shell mode.
  --export-type=[...]                            Export: File type:[svg,png,ps,psf,tex,emf,wmf,xaml]
  -o, --export-file=EXPORT-FILENAME              Export: File name
  --export-overwrite                             Export: Overwrite input file.
  --export-area=x0:y0:x1:y1                      Export: Area to export in SVG user units.
  -D, --export-area-drawing                      Export: Area to export is drawing (not page).
  -C, --export-area-page                         Export: Area to export is page.
  --export-margin                                Export: Margin around export area: units of page size for SVG, mm for PS/EPS/PDF.
  --export-area-snap                             Export: Snap the bitmap export area outwards to the nearest integer values.
  -w, --export-width=WIDTH                       Export: Bitmap width in pixels (overrides --export-dpi).
  -h, --export-height=HEIGHT                     Export: Bitmap height in pixels (overrides --export-dpi).
  -i, --export-id=OBJECT-ID[;OBJECT-ID]*         Export: ID(s) of object(s) to export.
  -j, --export-id-only                           Export: Hide all objects except object with ID selected by export-id.
  -l, --export-plain-svg                         Export: Remove items in the Inkscape namespace.
  -d, --export-dpi=DPI                           Export: Resolution for rasterization bitmaps and filters (default is 96).
  --export-ignore-filters                        Export: Render objects without filters instead of rasterizing. (PS/EPS/PDF)
  -T, --export-text-to-path                      Export: Convert text to paths. (PS/EPS/PDF/SVG).
  --export-ps-level=PS-Level                     Export: Postscript level (2 or 3). Default is 3.
  --export-pdf-level=PDF-Level                   Export: PDF level (1.4 or 1.5)
  --export-latex                                 Export: Export text separately to LaTeX file (PS/EPS/PDF). Include via \input{file.tex}
  -t, --export-use-hints                         Export: Use stored filename and DPI hints when exporting object selected by --export-id.
  -b, --export-background=COLOUR                 Export: Background color for exported bitmaps (any SVG color string).
  -y, --export-background-opacity=VALUE          Export: Background opacity for exported bitmaps (either 0.0 to 1.0 or 1 to 255).
  --xverbs=XVERBS-FILENAME                       Process: xverb command file.
mrpiggi commented 5 years ago

Well, since Inkscape 1.0 has alpha status, I actually do not want to adapt the svg package, because I can not assume that the interface will be implemented in the final version exactly as it is at the moment.

To be honest, I experimented with Inkscape 1.0 on the command line and did not manage to start an export call because I did not find out how to specify the original svg file. If you can give me a working export call as an example, then I could try to adjust the package accordingly, although I just do not know exactly how I could implement a test on the version of Inkscape used in each case.

willprice commented 5 years ago

Hi @mrpiggi, Thanks for the response. I understand your reluctance in implementing a feature for an alpha version of the software where the interface might change. For the record, the current way to export an SVG is like so:

$ inkscape my-image.svg --without-gui --export-type=pdf --export-file my-image.pdf
willprice commented 5 years ago

although I just do not know exactly how I could implement a test on the version of Inkscape used in each case.

I'm not sure if there are additional tests apart from the one in test, but you could perhaps have a shell script/batch file that runs all tests with inkscape 0.92 and 1.0 by manipulating $PATH providing you have a locally built version of 1.0.

mrpiggi commented 5 years ago

FYI Currently, there is a problem with the LaTeX export as the coordinates within the corresponding .pdf_tex files are upside down. Therefore I created an issue which was fixed very fast.

willprice commented 5 years ago

Thanks @mrpiggi!

Bivarapu commented 4 years ago

how to convert SVG file to Gcode file programtically in my project. like input file is SVG file process it finally get an Gcode file automatically with doing any action means One step conversion. SVG file(input)->process->Gcode(output)

mrpiggi commented 4 years ago

how to convert SVG file to Gcode file programtically in my project. like input file is SVG file process it finally get an Gcode file automatically with doing any action means One step conversion. SVG file(input)->process->Gcode(output)

How is this related to this latex package?

ibrahimrajabli commented 2 years ago

is inkscape 1.0a1 supports eps export? and how? I cant see eps export flag or something like "--export-type=eps"

mrpiggi commented 2 years ago

@ibrahimrajabli Are you sure, you are in the right place? Package svg is meant to be used with LaTeX documents. Tthere is no need to specify any flags, it is all done by the package. You could either use \includesvg[inkscapeformat=eps]{...} to invoke eps export with Inkscape or use package svg-extract in order to export the processed result to a standalone file via \includesvg[extractformat=eps]{...}

ibrahimrajabli commented 2 years ago

thanks for the information.