Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions writetex.inx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="preamble" type="string" _gui-text="Preamble File: "></param>
<param name="read-as-line" type="boolean" _gui-text="Trade above as contents">false</param>
<param name="fontsize" type="int" precision="1" min="10" max="12" _gui-text="Font Size">12</param>
<param name="scale" type="float" precision="2" min="0.1" max="50" _gui-text="Scale Factor">1</param>
<param name="action" type="notebook">
<page name="new" _gui-text="New TeX String">
Expand Down
20 changes: 12 additions & 8 deletions writetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ def __init__(self):
help="Read preamble as string")
self.OptionParser.add_option("-s", "--scale",
action="store", type="string",
dest="scale", default="",
dest="scale", default="1.0",
help="Scale Factor")
self.OptionParser.add_option("-i", "--inputfile",
action="store", type="string",
dest="inputfile", default="",
help="Read From File")
self.OptionParser.add_option("--fontsize",
action="store", type="string",
dest="fontsize", default="12",
help="Font size")
self.OptionParser.add_option("-c", "--pdftosvg",
action="store", type="string",
dest="pdftosvg", default="",
Expand Down Expand Up @@ -93,7 +97,7 @@ def effect(self):
print >>sys.stderr, node.attrib.get(
'{%s}text' % WriteTexNS, '').decode('string-escape')
return
print >>sys.stderr, "No text find."
print >>sys.stderr, "No text found."
return
else:
if action == "new":
Expand Down Expand Up @@ -127,15 +131,15 @@ def effect(self):
f.close()

self.tex = r"""
\documentclass[landscape,a3paper]{article}
\documentclass[%spt]{article}
\usepackage{geometry}
%s
\pagestyle{empty}
\begin{document}
\noindent
%s
\end{document}
""" % (preamble, self.text)
""" % (self.options.fontsize, preamble, self.text)

tex = open(tex_file, 'w')
tex.write(self.tex)
Expand Down Expand Up @@ -221,15 +225,15 @@ def svg_to_group(self, svgin):
try:
if self.options.rescale == 'true':
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
800*self.options.scale, 800*self.options.scale,
1000*self.options.scale, 1000*self.options.scale,
self.view_center[0],
self.view_center[1])
else:
if 'transform' in node.attrib:
newnode.attrib['transform'] = node.attrib['transform']
else:
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
800*self.options.scale, 800*self.options.scale,
1000*self.options.scale, 1000*self.options.scale,
self.view_center[0],
self.view_center[1])
newnode.attrib['style'] = node.attrib['style']
Expand All @@ -240,7 +244,7 @@ def svg_to_group(self, svgin):
p.append(newnode)
else:
newnode.attrib['transform'] = 'matrix(%f,0,0,%f,%f,%f)' % (
800*self.options.scale, 800*self.options.scale,
1000*self.options.scale, 1000*self.options.scale,
self.view_center[0],
self.view_center[1])
self.current_layer.append(newnode)
Expand Down Expand Up @@ -344,4 +348,4 @@ def parse_transform(transf):

if __name__ == '__main__':
e = WriteTex()
e.affect()
e.affect()