<commit_before>#!/bin/env python
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Name:         report/pdfprint.py
# Author:       <NAME> <<EMAIL>>
# Copyright:    (C) 2011 <NAME>.l. <NAME>, 122 18038 Sanremo (IM)
# ------------------------------------------------------------------------------
# This file is part of X4GA
#
# X4GA is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# X4GA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with X4GA.  If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------

import os, sys

import wx


def PdfPrint(filename, printer, copies=1, cbex=None, usedde=False, cmdprint=False, pdfcmd=None, commandprint=None):
    """ print a pdf """

    out = False
    if usedde:

        ## create a DDE connection and open acrobat if possible
        res = _checkAcrobatOpen(1, cbex)

        if not res:
            return

        ddeServer = res[0]
        ddeConv = res[1]

        try:
            for n in range(copies):
                if n>0:
                    wx.Sleep(1)
                ddeConv.Exec('[FilePrintTo("%s", "%s")]' % (filename, printer))
            out = True
        except:
            pass

        ddeServer.Destroy()

    if commandprint and bool(pdfcmd):
        import subprocess
        try:
            oldPar=commandprint.split()
            newPar=[]
            for p in oldPar:
                p=p.replace('<pgm_pdf>', pdfcmd)
                p=p.replace('<file_pdf>', filename)
                p=p.replace('<printer>', printer)
                newPar.append(p)
            for n in range(copies):                
                subprocess.Popen(newPar)
            out = True
        except:
            import awc.util as awu
            msg="Controllare Parametri per stampa diretta nel setup workstation."
            awu.MsgDialog(None, msg, style=wx.ICON_ERROR)
            pass


    if cmdprint and bool(pdfcmd):
        import subprocess
        try:
            subprocess.Popen([pdfcmd, '/t', filename, printer])
            out = True
        except:
            pass

    if cbex:
        cbex()

    return out

#------------------------------------------------------------------------------

def PdfView(filename, cbex=None, usedde=False, pdfcmd=None):

    out = False<commit_msg>Corretto bug che non teneva conto del numero di copie da stampare utilizzando l'opzione /t<commit_after>#!/bin/env python
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Name:         report/pdfprint.py
# Author:       <NAME> <<EMAIL>>
# Copyright:    (C) 2011 <NAME>. <NAME>, 122 18038 Sanremo (IM)
# ------------------------------------------------------------------------------
# This file is part of X4GA
#
# X4GA is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# X4GA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with X4GA.  If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------

import os, sys

import wx


def PdfPrint(filename, printer, copies=1, cbex=None, usedde=False, cmdprint=False, pdfcmd=None, commandprint=None):
    """ print a pdf """

    out = False
    if usedde:

        ## create a DDE connection and open acrobat if possible
        res = _checkAcrobatOpen(1, cbex)

        if not res:
            return

        ddeServer = res[0]
        ddeConv = res[1]

        try:
            for n in range(copies):
                if n>0:
                    wx.Sleep(1)
                ddeConv.Exec('[FilePrintTo("%s", "%s")]' % (filename, printer))
            out = True
        except:
            pass

        ddeServer.Destroy()

    if commandprint and bool(pdfcmd):
        import subprocess
        try:
            oldPar=commandprint.split()
            newPar=[]
            for p in oldPar:
                p=p.replace('<pgm_pdf>', pdfcmd)
                p=p.replace('<file_pdf>', filename)
                p=p.replace('<printer>', printer)
                newPar.append(p)
            for n in range(copies):                
                subprocess.Popen(newPar)
            out = True
        except:
            import awc.util as awu
            msg="Controllare Parametri per stampa diretta nel setup workstation."
            awu.MsgDialog(None, msg, style=wx.ICON_ERROR)
            pass


    if cmdprint and bool(pdfcmd):
        import subprocess
        try:
            for n in range(copies):                
                subprocess.Popen([pdfcmd, '/t', filename, printer])
            out = True
        except:
            pass

    if cbex:
        cbex()

    return out

#------------------------------------------------------------------------------

def PdfView(filename, cbex=None, usedde=False, pdfcmd=None):

    out = False
{'fraction_non_alphanumeric': 0.19273791085871622, 'fraction_numerical': 0.008260196179659268, 'mean_word_length': 1.4368972746331237, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '763658', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1502, 'n_words': 517}