private AllegatiElaborati? elaboraAllegato(DocumentInfo allegato, Persona persona, ParametriStampaUnione parametri, TipoMessaggio tipo, IConverter converter, int azienda)
        {
            AllegatiElaborati? result = null;
            byte[] body;
            
            if(persona != null)
                parametri.IdPersona = persona.ID;
    
            byte[] bodyAllegato = getBodyAllegato(allegato, parametri, azienda);
            var fileExtension = allegato.FileExtension;
            string fileName;
            try
            {
                if (tipo != TipoMessaggio.Manuale && (string.IsNullOrEmpty(allegato.FileExtension) || allegato.FileExtension != ".pdf"))
                {
                    body = converter.ConvertToPdf(allegato).ToArray();
                    fileExtension = ".pdf";
                }
                else
                    body = bodyAllegato;

                fileName = allegato.FileName;
                var index = fileName.LastIndexOf(".");
                if (index > 0)
                    fileName = fileName.Substring(0, index);
            }
            catch (Exception)
            {
                body = bodyAllegato;
                fileExtension = allegato.FileExtension;
                fileName = allegato.FileName;
                var index = fileName.LastIndexOf(".");
                if (index > 0)
                    fileName = fileName.Substring(0, index);
            }

            var documentMessage = getDocumentService().SaveDocument(bodyAllegato, allegato.FileName, allegato.FileExtension, null, _info.Azienda);
            if (documentMessage.Documento != null)
            {
                var documentoDto = documentMessage.Documento;
                allegato.FileId = documentoDto.Checksum;

                var documento = new DocumentInfo { Body = body, FileId = documentoDto.Checksum, FileName = fileName, FileExtension = fileExtension };
                result = new AllegatiElaborati(documento, allegato);
            }

            return result;
        }