summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2017-03-13 12:41:58 +0000
committerapenner <penner@vaxxine.com>2017-03-13 12:41:58 +0000
commit18b79811a187ecb630f11a841ffa686936f12614 (patch)
tree1b8a04aa780de60b149e4f422ba0ec85db49120a
parentextensions. dxf output & print_win32_vector. compensate for viewbox. (Bug 167... (diff)
downloadinkscape-18b79811a187ecb630f11a841ffa686936f12614.tar.gz
inkscape-18b79811a187ecb630f11a841ffa686936f12614.zip
Two Extensions for converting objects to paths before exporting. (Bug 1662531)
Fixed bugs: - https://launchpad.net/bugs/1662531 (bzr r15591)
-rw-r--r--share/extensions/prepare_file_save_as.inx16
-rw-r--r--share/extensions/prepare_file_save_as.py58
-rw-r--r--share/extensions/prepare_print_win32_vector.inx16
-rw-r--r--share/extensions/prepare_print_win32_vector.py64
4 files changed, 154 insertions, 0 deletions
diff --git a/share/extensions/prepare_file_save_as.inx b/share/extensions/prepare_file_save_as.inx
new file mode 100644
index 000000000..1556713aa
--- /dev/null
+++ b/share/extensions/prepare_file_save_as.inx
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Pre-Process File Save As...</_name>
+ <id>com.vaxxine.file.saveas.preprocess</id>
+ <dependency type="executable" location="extensions">prepare_file_save_as.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <effect>
+ <object-type>path</object-type>
+ <effects-menu>
+ <submenu _name="Export"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">prepare_file_save_as.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/prepare_file_save_as.py b/share/extensions/prepare_file_save_as.py
new file mode 100644
index 000000000..d0c660fcf
--- /dev/null
+++ b/share/extensions/prepare_file_save_as.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+'''
+file: prepare_file_save_as.py
+
+This extension will pre-process a vector image by applying the operations:
+'EditSelectAllInAllLayers' and 'ObjectToPath'
+before calling the dialog File->Save As....
+
+Copyright (C) 2014 Ryan Lerch (multiple difference)
+ 2016 Maren Hachmann <marenhachmannATyahoo.com> (refactoring, extend to multibool)
+ 2017 Alvin Penner <penner@vaxxine.com> (apply to 'File Save As...')
+
+This code is based on 'inkscape-extension-multiple-difference' by Ryan Lerch
+see : https://github.com/ryanlerch/inkscape-extension-multiple-difference
+also: https://github.com/Moini/inkscape-extensions-multi-bool
+It will call up a new instance of Inkscape and process the image there,
+so that the original file is left intact.
+
+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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+'''
+# standard library
+from subprocess import Popen, PIPE
+from shutil import copy2
+# local library
+import inkex
+
+class MyEffect(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+
+ def effect(self):
+ file = self.args[-1]
+ tempfile = inkex.os.path.splitext(file)[0] + "-prepare.svg"
+ # tempfile is needed here only because we want to force the extension to be .svg
+ # so that we can open and close it silently
+ copy2(file, tempfile)
+ p = Popen('inkscape --verb=EditSelectAllInAllLayers --verb=EditUnlinkClone --verb=ObjectToPath --verb=FileSaveACopy --verb=FileSave --verb=FileQuit '+tempfile, shell=True, stdout=PIPE, stderr=PIPE)
+ err = p.stderr
+ f = p.communicate()[0]
+ err.close()
+
+if __name__ == '__main__':
+ e = MyEffect()
+ e.affect()
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
diff --git a/share/extensions/prepare_print_win32_vector.inx b/share/extensions/prepare_print_win32_vector.inx
new file mode 100644
index 000000000..b8d87cec8
--- /dev/null
+++ b/share/extensions/prepare_print_win32_vector.inx
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Pre-Process Win32 Vector Print</_name>
+ <id>com.vaxxine.print.win32.preprocess</id>
+ <dependency type="executable" location="extensions">prepare_print_win32_vector.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <effect>
+ <object-type>path</object-type>
+ <effects-menu>
+ <submenu _name="Export"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">prepare_print_win32_vector.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/prepare_print_win32_vector.py b/share/extensions/prepare_print_win32_vector.py
new file mode 100644
index 000000000..e13670931
--- /dev/null
+++ b/share/extensions/prepare_print_win32_vector.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+'''
+file: prepare_print_win32_vector.py
+
+This extension will pre-process a vector image by applying the operations:
+'EditSelectAllInAllLayers' and 'ObjectToPath'
+before applying the extension: 'Win32 Vector Print'.
+
+Generate vector graphics printout, specifically for Windows GDI32.
+
+Copyright (C) 2014 Ryan Lerch (multiple difference)
+ 2016 Maren Hachmann <marenhachmannATyahoo.com> (refactoring, extend to multibool)
+ 2017 Alvin Penner <penner@vaxxine.com> (apply to 'Win32 Vector Print')
+
+This code is based on 'inkscape-extension-multiple-difference' by Ryan Lerch
+see : https://github.com/ryanlerch/inkscape-extension-multiple-difference
+also: https://github.com/Moini/inkscape-extensions-multi-bool
+It will call up a new instance of Inkscape and process the image there,
+so that the original file is left intact.
+
+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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+'''
+# standard library
+from subprocess import Popen, PIPE
+from shutil import copy2
+# local library
+import inkex
+
+inkex.localize() # Initialize gettext
+if not inkex.sys.platform.startswith('win'):
+ exit(_("sorry, this will run only on Windows, exiting..."))
+
+class MyEffect(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+
+ def effect(self):
+ file = self.args[-1]
+ tempfile = inkex.os.path.splitext(file)[0] + "-prepare.svg"
+ # tempfile is needed here only because we want to force the extension to be .svg
+ # so that we can open and close it silently
+ copy2(file, tempfile)
+ p = Popen('inkscape --verb=EditSelectAllInAllLayers --verb=EditUnlinkClone --verb=ObjectToPath --verb=com.vaxxine.print.win32 --verb=FileSave --verb=FileQuit '+tempfile, shell=True, stdout=PIPE, stderr=PIPE)
+ err = p.stderr
+ f = p.communicate()[0]
+ err.close()
+
+if __name__ == '__main__':
+ e = MyEffect()
+ e.affect()
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99