HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/share/inkscape/extensions/empty_business_card.py
#!/usr/bin/env python

# Written by Tavmjong Bah

import inkex
import re

class C(inkex.Effect):
  def __init__(self):
    inkex.Effect.__init__(self)
    self.OptionParser.add_option("-s", "--size",   action="store", type="string", dest="card_size",   default="90mmx55mm",   help="Business card size")

  def effect(self):

    size   = self.options.card_size

    p = re.compile('([0-9.]*)([a-z][a-z])x([0-9.]*)([a-z][a-z])')
    m = p.match( size )
    width       = m.group(1)
    width_unit  = m.group(2)
    height      = m.group(3)
    height_unit = m.group(4)

    root = self.document.getroot()
    root.set("id", "SVGRoot")
    root.set("width",  width + width_unit)
    root.set("height", height + height_unit)
    root.set("viewBox", "0 0 " + width + " " + height )

    namedview = root.find(inkex.addNS('namedview', 'sodipodi'))
    if namedview is None:
        namedview = inkex.etree.SubElement( root, inkex.addNS('namedview', 'sodipodi') );
     
    namedview.set(inkex.addNS('document-units', 'inkscape'), width_unit)

    width_int  = int(self.uutounit(float(width), 'px'))
    height_int = int(self.uutounit(float(height), 'px'))

    namedview.set(inkex.addNS('zoom',      'inkscape'), str(2) )
    namedview.set(inkex.addNS('cx',        'inkscape'), str(width_int/2.0) )
    namedview.set(inkex.addNS('cy',        'inkscape'), str(height_int/2.0) )


c = C()
c.affect()