# -*- coding: utf-8 -*-

"""
This program receive the name of a xml b2b invoice as input parameter.
A pdf file is generated applying the Assosoftware's style sheet.
The name of the input xml file and the output pdf file are passed as parameteres
"""

import sys
import os
import lxml.etree as let
import pdfkit


# definisce il trasformatore dell'xml secondo il foglio di stile assosoftware
xslt = let.parse(os.path.dirname(os.path.realpath(__file__)) + "/FoglioStileAssoSoftware.xsl")
transform = let.XSLT(xslt)

dom = let.fromstring(open(sys.argv[1], 'r').read())
newdom = transform(dom)
html = let.tostring(newdom)
pdf = pdfkit.from_string(html, sys.argv[2])
