Mercurial > hg > python
annotate vec2svg-2.py @ 60:bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Wed, 13 Dec 2023 17:31:28 +0000 |
parents | f67f9ea191b7 |
children |
rev | line source |
---|---|
43
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 """ |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
2 vec2svg.py |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
3 Copyright 2009 XEROX |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
4 """ |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 import libxml2 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 from optparse import OptionParser |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
9 sSVGNs = "svg" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
10 sSVGNsURI = "http://www.w3.org/2000/svg" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 gnsSVG = None |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
12 def generatePath(doc,node): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
13 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
14 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
15 pathNode = libxml2.newNode("path") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
16 pathNode.setNs(gnsSVG) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
17 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
18 ctxt = doc.xpathNewContext() |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
19 xpath = "./M|L|C" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
20 ctxt.setContextNode(node) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
21 lInstruction= ctxt.xpathEval(xpath) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
22 ctxt.xpathFreeContext() |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
23 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
24 sPath="" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
25 for inst in lInstruction: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
26 if inst.name =="M" or inst.name =="L": |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
27 sPath = sPath + "%s %g %g " % (inst.name, float(inst.prop("x")), float(inst.prop("y"))) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
28 elif inst.name == "C": |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
29 sPath = sPath + "%s %g %g %g %g %g %g " % (inst.name, float(inst.prop("x1")),\ |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
30 float(inst.prop("y1")), float(inst.prop("x2")),\ |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
31 float(inst.prop("y2")),float(inst.prop("x3")),float(inst.prop("y3"))) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
32 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
33 pathNode.newProp("d", sPath) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
34 return pathNode |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
35 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
36 def generateSVG(node, doc): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
37 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
38 ## vectors |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
39 ctxt = doc.xpathNewContext() |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
40 xpath = "./%s" % ("GROUP") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
41 ctxt.setContextNode(node) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
42 lGroup= ctxt.xpathEval(xpath) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
43 ctxt.xpathFreeContext() |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
44 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
45 image = libxml2.newDoc("1.0") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
46 svgRoot = libxml2.newNode("svg") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
47 svgRoot.newNs(sSVGNsURI, None) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
48 svgRoot.newNs("http://www.w3.org/1999/xlink","xlink") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
49 svgRoot.setNs(gnsSVG) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
50 image.setRootElement(svgRoot) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
51 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
52 for elt in lGroup: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
53 svgg = libxml2.newNode("g") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
54 svgRoot.addChild(svgg) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
55 svgg.setNs(gnsSVG) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
56 svgg.setProp("style", elt.prop("style")) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
57 path = generatePath(doc,elt) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
58 svgg.addChild(path) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
59 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
60 return image |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
61 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
62 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
63 def loadDom(filename): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
64 doc = libxml2.parseFile(filename) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
65 return doc |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
66 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
67 def add_option(parser,*args, **kwargs): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
68 """add a new command line option to the parser""" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
69 parser.add_option(*args, **kwargs) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
70 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
71 def parseCommandLine(parser): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
72 (options, args) = parser.parse_args() |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
73 dOptions = {} |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
74 for k,v in options.__dict__.items(): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
75 if v != None: dOptions[k] = v |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
76 return dOptions |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
77 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
78 def writeDom(outFile,doc, bIndent=False): |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
79 if bIndent: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
80 doc.saveFormatFile(outFile, bIndent) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
81 else: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
82 doc.saveFile(outFile) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
83 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
84 if __name__ == "__main__": |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
85 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
86 dParams = {} |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
87 usage="python vec2svg.py -i inputFile -o outputFile" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
88 parser = OptionParser(usage, version="0.1") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
89 parser.description = ".vec to .svg conversion" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
90 add_option(parser,"-i", "--input", dest="input", default="", action="store", type="string", help="input file (.vec)", metavar="<file>") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
91 add_option(parser,"-o", "--output", dest="output", default="-", action="store", type="string", help="output file (SVG)", metavar="<file>") |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
92 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
93 dParams = parseCommandLine(parser) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
94 bInput = "input" in dParams |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
95 if bInput: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
96 inputFileName = dParams["input"] |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
97 print(inputFileName) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
98 bOutput = "output" in dParams |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
99 if bOutput: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
100 outputFileName = dParams["output"] |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
101 else: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
102 output = "-" |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
103 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
104 doc = loadDom(inputFileName) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
105 svgFile = generateSVG(doc.getRootElement(), doc) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
106 writeDom(outputFileName,svgFile) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
107 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
108 else: |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
109 print(usage) |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
110 |
f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
111 |