public static GeneratePdfService.GeneratePDFServiceService getGeneratePdfService() { try { if (!string.IsNullOrEmpty(serverLiveCycle) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(generatePdfService) ) { //Creo il servizio generatePdfService GeneratePdfService.GeneratePDFServiceService serviceGeneratePdf = new GeneratePdfService.GeneratePDFServiceService(); serviceGeneratePdf.Timeout = System.Threading.Timeout.Infinite; //Imposto l'URL dei web services //generatePdfService.Url = serverLiveCycle + "GeneratePdfService?wsdl&blob=base64"; serviceGeneratePdf.Url = generatePdfService + "&blob=base64"; //Autenticazione serviceGeneratePdf.Credentials = new System.Net.NetworkCredential(username, password); return(serviceGeneratePdf); } else { return(null); } } catch (Exception e) { logger.Error("Errore in LiveCycle - LCServicesManager - metodo: getGeneratePdfService()", e); return(null); } }
public static DocsPaVO.documento.FileDocumento generatePdfService(DocsPaVO.documento.FileDocumento fileDocumento) { try { //Istanzio il servizio GeneratePdfService.GeneratePDFServiceService generatePdf = LCServicesManager.getGeneratePdfService(); if (generatePdf != null) { //Popolo il binaryData del BLOB GeneratePdfService.BLOB inDoc = new GeneratePdfService.BLOB(); inDoc.binaryData = fileDocumento.content; //Sepcifico le opzioni PDF e Security //String adobePDFSettings = "Standard"; //String securitySettings = "No Security"; //String fileTypeSettings = "Standard"; String adobePDFSettings = "PDFA1b 2005 CMYK"; String securitySettings = "No Security"; String fileTypeSettings = "Standard PITRE"; //String fileTypeSettings = "Standard OCR"; byte[] resultBinaryFile = null; //Converto in pdf GeneratePdfService.mapItem[] createPDFResults = generatePdf.CreatePDF(inDoc, fileDocumento.name, fileTypeSettings, adobePDFSettings, securitySettings, null, null); generatePdf.Dispose(); //Recupero il file convertito in pdf for (int count = 0; count < createPDFResults.Length; ++count) { //Recupero un elemento dalla mappa GeneratePdfService.mapItem mapEntry = createPDFResults[count]; String mapKey = mapEntry.key as String; //La chiave della mappa del documento convertito sarà "ConvertedDoc" if (mapKey.Equals("ConvertedDoc")) { GeneratePdfService.BLOB resultBlob = mapEntry.value as GeneratePdfService.BLOB; resultBinaryFile = resultBlob.binaryData; } } fileDocumento.fullName = System.IO.Path.GetFileNameWithoutExtension(fileDocumento.fullName) + ".pdf"; fileDocumento.name = System.IO.Path.GetFileNameWithoutExtension(fileDocumento.name) + ".pdf"; fileDocumento.contentType = "application/pdf"; fileDocumento.content = resultBinaryFile; //Faillace, segnalazione tiket 266571 //Inserita l'estensione e modifica nome file orginale. fileDocumento.estensioneFile = "pdf"; if (!String.IsNullOrEmpty(fileDocumento.nomeOriginale)) { fileDocumento.nomeOriginale = System.IO.Path.GetFileNameWithoutExtension(fileDocumento.nomeOriginale) + ".pdf"; } return(fileDocumento); } else { return(null); } } catch (Exception e) { logger.Error("Errore in LiveCycle - LCServices - metodo: generatePdfService()", e); return(null); } }