diff options
-rw-r--r-- | fedora_business_cards/frontend/cmdline.py | 9 | ||||
-rw-r--r-- | fedora_business_cards/generate.py | 23 | ||||
-rw-r--r-- | templates/back-northamerica.svg | 53 | ||||
-rw-r--r-- | templates/front-northamerica.svg | 71 |
4 files changed, 138 insertions, 18 deletions
diff --git a/fedora_business_cards/frontend/cmdline.py b/fedora_business_cards/frontend/cmdline.py index 958aa33..b14fe3a 100644 --- a/fedora_business_cards/frontend/cmdline.py +++ b/fedora_business_cards/frontend/cmdline.py @@ -58,6 +58,10 @@ def main(): parser.add_option("-u", "--username", dest="username", default="", help="If set, use a different name than the one logged"+\ " in with to fill out business card information") + parser.add_option("-x", "--width", dest="width", default="", + help="If set, use a different height") + parser.add_option("-y", "--height", dest="height", default="", + help="If set, use a different width") parser.add_option("--pdf", dest="output", default="png", const="pdf", action="store_const", help="Export as PDF") parser.add_option("--png", dest="output", default="png", const="png", @@ -149,7 +153,8 @@ def main(): # generate front of business card print "Generating front...", sys.stdout.flush() - xml = generate.gen_front(name, title, lines, frontloc) + xml = generate.gen_front(name, title, lines, frontloc, + options.width, options.height) if options.output == "svg": export.svg_to_file(xml, options.username+'-front.'+options.output) elif options.output == "cmyk_pdf": @@ -160,7 +165,7 @@ def main(): # generate back of business card print "Generating back...", sys.stdout.flush() - xml = generate.gen_back(backloc) + xml = generate.gen_back(backloc, options.width, options.height) if options.output == "svg": export.svg_to_file(xml, options.username+'-back.'+options.output) elif options.output == "cmyk_pdf": diff --git a/fedora_business_cards/generate.py b/fedora_business_cards/generate.py index 91f1e14..cf2b4e1 100644 --- a/fedora_business_cards/generate.py +++ b/fedora_business_cards/generate.py @@ -37,24 +37,43 @@ def find_node(doc_node, tag_name, attribute_name, attribute_value): return element -def gen_front(name, title, lines, template_loc): +def gen_front(name, title, lines, template_loc, width=None, height=None): """ Generates the front of the business card. """ dom = minidom.parse(template_loc) + namenode = find_node(dom, 'text', 'id', 'fullname') namenode.appendChild(dom.createTextNode(name)) titlenode = find_node(dom, 'text', 'id', 'title') titlenode.appendChild(dom.createTextNode(title)) + if width or height: + svg = find_node(dom, 'svg', 'id', 'svg') + svg.setAttribute('width', width) + svg.setAttribute('height', height) + svg.setAttribute('viewBox', '0 0 '+width+' '+height) + whiteness = find_node(dom, 'rect', 'id', 'whiteness') + whiteness.setAttribute('height', height) + blueband = find_node(dom, 'rect', 'id', 'blueband') + blueband.setAttribute('height', height) + blueband.setAttribute('width', width) for i in range(6): node = find_node(dom, 'tspan', 'id', 'line%d' % (i+1)) node.appendChild(dom.createTextNode(lines[i])) return dom.toxml() -def gen_back(template_loc): +def gen_back(template_loc, width=None, height=None): """ Generates the back of the business card. """ dom = minidom.parse(template_loc) + if width or height: + svg = find_node(dom, 'svg', 'id', 'svg') + svg.setAttribute('width', width) + svg.setAttribute('height', height) + svg.setAttribute('viewBox', '0 0 '+width+' '+height) + background = find_node(dom, 'rect', 'id', 'background') + background.setAttribute('width', width) + background.setAttribute('height', height) return dom.toxml() diff --git a/templates/back-northamerica.svg b/templates/back-northamerica.svg index 942c4a7..4b0943c 100644 --- a/templates/back-northamerica.svg +++ b/templates/back-northamerica.svg @@ -1,21 +1,68 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" width="3.5in" height="2in" viewBox="0 0 315 180" - id="svg3784"> + id="svg" + sodipodi:version="0.32" + inkscape:version="0.46" + sodipodi:docname="back-northamerica.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <metadata + id="metadata20"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + inkscape:window-height="753" + inkscape:window-width="1236" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + guidetolerance="10.0" + gridtolerance="10.0" + objecttolerance="10.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + showgrid="false" + inkscape:zoom="1.7174603" + inkscape:cx="157.5" + inkscape:cy="90" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:current-layer="svg" /> <defs - id="defs22" /> + id="defs22"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 90 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="315 : 90 : 1" + inkscape:persp3d-origin="157.5 : 60 : 1" + id="perspective22" /> + </defs> <rect width="315" height="180" x="0" y="0" - id="rect2746" + id="background" style="fill:#3c6eb4;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> <g id="g3267"> diff --git a/templates/front-northamerica.svg b/templates/front-northamerica.svg index 4bae12f..912e551 100644 --- a/templates/front-northamerica.svg +++ b/templates/front-northamerica.svg @@ -2,16 +2,62 @@ <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" width="3.5in" height="2in" viewBox="0 0 315 180" - id="svg2"> + id="svg" + sodipodi:version="0.32" + inkscape:version="0.46" + sodipodi:docname="front-northamerica.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <metadata + id="metadata35"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + inkscape:window-height="753" + inkscape:window-width="1236" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + guidetolerance="10.0" + gridtolerance="10.0" + objecttolerance="10.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + showgrid="false" + inkscape:zoom="1.7174603" + inkscape:cx="157.5" + inkscape:cy="90" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:current-layer="svg" /> <defs id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 90 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="315 : 90 : 1" + inkscape:persp3d-origin="157.5 : 60 : 1" + id="perspective37" /> <foreignObject id="foreignObject8" height="1" @@ -27,16 +73,16 @@ width="315" height="180" x="0" - y="1.9248492e-14" - id="rect2409" - style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + y="0" + id="blueband" + style="fill:#3c6eb4;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> <rect - width="18" + width="300" height="180" - x="297" + x="0" y="0" - id="rect3330" - style="fill:#3c6eb4;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + id="whiteness" + style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> <g transform="translate(0,-35.732645)" id="g3974"> @@ -45,19 +91,22 @@ y="63.477001" id="fullname" xml:space="preserve" - style="font-size:13px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna" /> + style="font-size:13px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna" + sodipodi:linespacing="125%" /> <text x="18" y="75.477005" id="title" xml:space="preserve" - style="font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna" /> + style="font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna" + sodipodi:linespacing="125%" /> <text x="18" y="93.010002" id="text3534" xml:space="preserve" - style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"><tspan + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna" + sodipodi:linespacing="100%"><tspan x="18" y="93.010002" id="line1" |