import json # open the guide file and extract the guide path with open("at.svg") as f: bytestring = f.read() # interpret the svg as an XML document and remove the "guide" group tree = lxml.etree.fromstring(bytestring) viewBox = tree.attrib['viewBox'] dx, dy, w, h = map(float, viewBox.split()) print dx, dy g = tree.xpath("//*[@id='guide']")[0] guide = g[0].attrib['d'] points = Bezier.parse_svg(guide) curve = Bezier(points) tree.remove(g) bytestring = lxml.etree.tostring(tree) print_width_mm = 72 resolution_dpi = 180 width_pixels = int(72/25.4 * 180) # set up the printer context printer = win32print.GetDefaultPrinter() print printer phandle = win32print.OpenPrinter(printer) dc = win32ui.CreateDC() dc.CreatePrinterDC()