summaryrefslogtreecommitdiff
path: root/support/autolatex/translators/svg2pdf+tex_inkscape.transdef
blob: da5c2f7ab73fdc6081aade24259d82e054a937a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# autolatex - svg2pdf+tex_inkscape.transdef
# Copyright (C) 2013  Stephane Galland <galland@arakhne.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

#--------------------------------------------
# See template.txt for details on the fields
#--------------------------------------------

INPUT_EXTENSIONS = .svgt .svg_t .svgtex .svg+tex .tex.svg +tex.svg .svgzt .svgz_t .svgztex .svgz+tex .tex.svgz +tex.svgz

OUTPUT_EXTENSIONS for pdf = .pdf .pdftex_t
OUTPUT_EXTENSIONS for eps = .eps .pstex_t

TRANSLATOR_FUNCTION =<<EOL {
	my ($ext1, $ext2, $opt);
	if ($ispdfmode) {
		$ext1 = '.pdf_tex';
		$ext2 = '.pdftex_t';
		$opt = '--export-pdf';
	}
	else {
		$ext1 = '.eps_tex';
		$ext2 = '.pstex_t';
		$opt = '--export-eps';
	}
	# Compute the name of the generated PDFTEX file
	my $pdftexfile = File::Spec->catfile(
			dirname("$in"),
			basename("$out", @outexts).$ext1);
	# Compute the name of the generated PDFTEX file
	my $pdftexfile2 = File::Spec->catfile(
			dirname("$in"),
			basename("$out", @outexts).$ext2);
	# Generation of the output from SVG
	runCommandOrFail(
		'inkscape',
		'--without-gui',
		'--export-area-page',
		$opt,
		"$out",
		'--export-latex',
		"--file=$in");
	# Remove temp file
	move("$pdftexfile", "$pdftexfile2") or printErr("$pdftexfile -> $pdftexfile2: $!");
}
EOL

FILES_TO_CLEAN = $out.pdftex_t $out.pstex_t