private void FirmarFacturaToolStripMenuItemClick(object sender, EventArgs e) { using (OpenFileDialog openCertificadoFileDialog = new OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal), Title = FacturasRecursos.Form1_firmarFacturaToolStripMenuItem_Click_Seleccione_su_certificado_de_usuario, Filter = FacturasRecursos.Form1_firmarFacturaToolStripMenuItem_Click_Certificado_Digital____p12____p12 }) { if (openCertificadoFileDialog.ShowDialog(this) == DialogResult.OK) { if (!string.IsNullOrEmpty(openCertificadoFileDialog.FileName)) { Passs pass = new Passs(); if (pass.ShowDialog() == DialogResult.OK) { Cert myCert = null; try { myCert = new Cert(openCertificadoFileDialog.FileName, pass.Password); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, Application.ProductName); return; } OpenFileDialog openFileDialog = new OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal), Title = FacturasRecursos. Form1_firmarFacturaToolStripMenuItem_Click_Seleccione_una_factura_sin_firmar, Filter = FacturasRecursos. Form1_firmarFacturaToolStripMenuItem_Click_Factura____pdf____pdf }; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { if (!string.IsNullOrEmpty(openFileDialog.FileName)) { MetaData myMd = new MetaData(); myMd.Author = Settings.Default.nombre; myMd.Title = string.Format("Factura emitida por {0}", Settings.Default.nombre); myMd.Subject = "Factura por translado en taxi"; myMd.Keywords = "factura, taxi, mariano"; myMd.Creator = "Riccardo Prieto Mendoza"; myMd.Producer = "Riccardo Prieto Mendoza"; using (SaveFileDialog sabeD = new SaveFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal), Title = FacturasRecursos.Form1_firmarFacturaToolStripMenuItem_Click_Guardar_Factura_Firmada_como___, Filter = FacturasRecursos.Form1_firmarFacturaToolStripMenuItem_Click_Factura____pdf____pdf }) { if (sabeD.ShowDialog(this) == DialogResult.OK) { PdfSigner pdfs = new PdfSigner(openFileDialog.FileName, sabeD.FileName, myCert, myMd); pdfs.Sign("Factura por translado en taxi", Settings.Default.email, Settings.Default.direccion + " " + Settings.Default.poblacionCP, false); Process.Start(sabeD.FileName); } } } } } } } } }