示例#1
0
    def __init__(self, slafile=None, label=None, report=None, objects=None,
                 daos=None, slaFileName=None, pdfFolder=None, classic=None,
                 template_file=None, pbar=None):


        SlaParser.__init__(self, slaFileName=slaFileName,
                           pdfFolder=pdfFolder,
                           slafile=slafile)
        self.slaFileName = slaFileName
        self.report = report
        self.classic = classic
        self.template_file = template_file
        self.daos = daos
        self.objects = objects
        self.pbar = pbar
        self.label = label
        self.formatFunctions = ['trunc', 'approx', 'itformat',
                                'itformatdataora', 'itformatdata',
                                'bcview', "approxit"]
        self.timeTags = ['date', 'time', 'datetime']
        self.positionTags = ['first', 'last']
        self.pageTags = ['currentPage', 'totalPage']
        self.cycle = 0
        # in slaparser in quanto server anche dopo per sla2pdf
#        self.findTablesAndTags()
        #questa è una funzione chiave .....
        self.tableProperties = self.findTablesProperties()
        for l in self.pageObjects:
            if l.get("ANNAME") == "LOGO_AZIENDA":
                if l.get("PFILE") == "":
                    if "azi_percorso_immagine" in objects[0] and objects[0]["azi_percorso_immagine"] != ""\
                    and objects[0]["azi_percorso_immagine"]:
                        try:
                            log_path = objects[0]["azi_percorso_immagine"]
                            l.set("PFILE", os.path.relpath(log_path,os.path.expanduser('~')))
                            print os.path.relpath(log_path,os.path.expanduser('~'))
                        except Exception as e:
                            Environment.pg2log.info("ERRORE NELL'INSERIMENTO DEL LOGO"+str(e.args))
        self.pagesNumber = self.getPagesNumber()
        if self.label and self.classic:
            self.duplicateElementLabel()
        if self.pagesNumber >1:
            self.addEmptyPages()
        if not self.label:
            self.duplicateElement(self.pagesNumber)
            self.duplicateTags()
            self.doc.write(self.pdfFolder+"_sla_prima_del_fill.sla")
            self.fillDocument()
        elif self.label and not self.classic:
            self.duplicateElement(self.pagesNumber)
            #self.duplicateTags()
            self.labelSla()

#        self.fillDocument()
        self.doc.write(self.pdfFolder+"_temppp.sla")
示例#2
0
    def __init__(self, pdfFolder=None, slaFileName = None, fileName= None,
                                                    slafile = None, pbar=None):
        """
        Build a template object based on the specified file-like
        object and sequence of objects
        """

        self.pdfFolder = pdfFolder
        self.slaFileName = slaFileName
        self.pbar = pbar
        SlaParser.__init__(self, slaFileName=slaFileName,
                                    pdfFolder=pdfFolder,
                                    slafile=slafile)
        self.document = None
#        self.version = self.scribusVersion()
        self.version = True
        self.numPages = len(self.slaPage())