Not synchronized with metadata property after PdfFileSignature.Sign

Hola

tengo un problema tras firmar pdf’s

creo un pdf desde una plantilla de word con mergemail y todo ok

PdfSaveOptions opts = new PdfSaveOptions();
opts.SaveFormat = Aspose.Words.SaveFormat.Pdf;
opts.Compliance = PdfCompliance.PdfA1a;
doc.Save(ruta,opts);

lo guardo como pdf/a-1a y todo ok

pero tras firmarlo con este metodo:

using (var pdfFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
pdfFileSignature.BindPdf(ruta);
var cert = new Aspose.Pdf.Forms.PKCS1(certPath, claveCertificado)
{

    Reason = "Firma Digital",
    ContactInfo = "mail@Address.com",
    Location = "Aqui",
    Date = DateTime.Now,
    CustomAppearance = new Aspose.Pdf.Forms.SignatureCustomAppearance
    {
        DigitalSignedLabel = "Firmado por ",
        DateSignedAtLabel = "Fecha ",
        FontSize = 6,
        FontFamilyName = "Arial",
        DateTimeFormat = "yyyy-MM-dd HH:mm:ss",
        ShowContactInfo = false,
        ShowLocation = false,
        ShowReason = false,                            
        Culture = System.Globalization.CultureInfo.InvariantCulture
        
    }
};

// Obtener dimensiones de la última página
var tempDoc = new Aspose.Pdf.Document(ruta);
int paginaFinal = tempDoc.Pages.Count;
var rectPagina = tempDoc.Pages[paginaFinal].GetPageRect(true);
float ancho = (float)rectPagina.Width * 0.40f;
float alto = 30;
float x = 20;
float y = 20;

System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)x, (int)y, (int)ancho, (int)alto);

pdfFileSignature.Sign(paginaFinal, true, rect, cert);
pdfFileSignature.Save(rutaFirmado);

}

me da error en la validacion

docF.Validate(rutaXML, Aspose.Pdf.PdfFormat.PDF_A_1A);

xml de la validacion:

1.0 Copyright (c) 2001-2025 Aspose Pty Ltd. All Rights Reserved. 29/07/2025 17:13:36 Document information entry 'Creator' not synchronized with metadata property 'xmp:CreatorTool' Document information entry 'Producer' not synchronized with metadata property 'pdf:Producer'

quedo a esperas de sus comentarios

Saludos

@InformaticaAdarve

Hola,

Parece que estás enfrentando un problema de sincronización entre la información del documento y las propiedades de metadatos después de firmar el PDF. Los errores que mencionas indican que las entradas de información del documento, como ‘Creator’ y ‘Producer’, no están alineadas con las propiedades de metadatos correspondientes.

Causa: Este problema puede surgir si los metadatos no están correctamente configurados antes de la firma del documento.

Solución: Aquí hay algunos pasos que puedes seguir para resolver este problema:

  1. Verifica y actualiza los metadatos: Antes de firmar el PDF, asegúrate de que los metadatos del documento estén correctamente configurados. Puedes hacerlo utilizando el objeto Document de Aspose.Pdf para establecer los metadatos necesarios.

    var pdfDocument = new Aspose.Pdf.Document(ruta);
    pdfDocument.Info.Creator = "Tu Nombre o Herramienta";
    pdfDocument.Info.Producer = "Aspose.PDF";
    pdfDocument.Save(ruta);
    
  2. Firma el documento: Después de asegurarte de que los metadatos estén correctos, procede a firmar el documento como lo has estado haciendo.

  3. Valida el PDF/A: Una vez que hayas firmado el documento, realiza la validación nuevamente para verificar que los metadatos estén sincronizados.

Próximos pasos: Si después de seguir estos pasos sigues teniendo problemas, revisa si hay alguna configuración adicional en el proceso de firma que pueda estar afectando los metadatos.

Si necesitas más asistencia o tienes más preguntas, no dudes en preguntar. Estoy aquí para ayudarte.

¡Espero que esto te ayude!

1 Like

@Professionalize.Discourse

Muchas Gracias

era exactamente el problema, tal vez era tan simple que no lo veía

quedó perfecto a la primera

Saludos

@InformaticaAdarve

È bello sapere che il tuo problema è stato risolto. Continua a utilizzare l’API e sentiti libero di creare un nuovo argomento nel caso in cui riscontri qualsiasi tipo di problema.

Buenos dias

me ha vuelto a aparecer el error

[2025-07-30 13:03:30] Metadatos → Original tras generar el pdf mediante mailmerge (aspose.word)
[2025-07-30 13:03:30] xmp:CreatorTool: Microsoft Office Word
[2025-07-30 13:03:30] pdf:Producer : Aspose.Words for .NET 25.4.0
[2025-07-30 13:03:30] Info.Creator : Microsoft Office Word
[2025-07-30 13:03:30] Info.Producer : Aspose.Words for .NET 25.4.0

[2025-07-30 13:03:31] Metadatos Modificados → tras guardar el pdf he modificado como me sugirio @Professionalize.Discourse
[2025-07-30 13:03:31] xmp:CreatorTool: Prueba
[2025-07-30 13:03:31] pdf:Producer : Aspose.PDF
[2025-07-30 13:03:31] Info.Creator : Prueba
[2025-07-30 13:03:31] Info.Producer : Aspose.PDF

[2025-07-30 13:03:33] – INICIO FirmarPDF
[2025-07-30 13:03:33] Metadatos Antes de firmar en Facades.PdfFileSignature
[2025-07-30 13:03:33] xmp:CreatorTool: Prueba
[2025-07-30 13:03:33] pdf:Producer : Aspose.PDF
[2025-07-30 13:03:33] Info.Creator : Prueba
[2025-07-30 13:03:33] Info.Producer : Aspose.PDF
[2025-07-30 13:03:34] – FIN FirmarPDF

[2025-07-30 13:03:35] Metadatos Firmados →
[2025-07-30 13:03:35] xmp:CreatorTool: Prueba
[2025-07-30 13:03:35] pdf:Producer : Aspose.PDF
[2025-07-30 13:03:35] Info.Creator : Aspose Pty Ltd.
[2025-07-30 13:03:35] Info.Producer : Aspose.PDF for .NET 25.4.0

1.0 Copyright (c) 2001-2025 Aspose Pty Ltd. All Rights Reserved. 30/07/2025 13:03:35 Document information entry 'Creator' not synchronized with metadata property 'xmp:CreatorTool' Document information entry 'Producer' not synchronized with metadata property 'pdf:Producer'

lo único que veo es que utilizo otra ruta para guardar el pdf firmado y eso haga que se creen nuevos metadatos

pdfFileSignature.BindPdf(ruta);
pdfFileSignature.Save(rutaFirmado);

Aqui el codigo que utilizo para la frima:

using (var pdfFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
    pdfFileSignature.BindPdf(ruta); //Ruta Original
    MisLogs.Log($"Metadatos Antes de firmar en Facades.PdfFileSignature");
    MisLogs.Log($"xmp:CreatorTool: {pdfFileSignature.Document.Metadata["xmp:CreatorTool"]}");
    MisLogs.Log($"pdf:Producer   : {pdfFileSignature.Document.Metadata["pdf:Producer"]}");
    MisLogs.Log($"Info.Creator   : {pdfFileSignature.Document.Info.Creator}");
    MisLogs.Log($"Info.Producer  : {pdfFileSignature.Document.Info.Producer}");

    pdfFileSignature.Document.Info.Creator = "Prueba";
    pdfFileSignature.Document.Info.Producer = "Aspose.PDF";
    pdfFileSignature.Document.Info.Author = "Prueba";
    pdfFileSignature.Document.Metadata["xmp:CreatorTool"] = "Prueba";
    pdfFileSignature.Document.Metadata["pdf:Producer"] = "Aspose.PDF";

    var cert = new Aspose.Pdf.Forms.PKCS1(certPath, claveCertificado)
    {

        Reason = "Firma Digital",
        ContactInfo = "notificacione@adarvecorporacion.com",
        Location = "Madrid",
        Date = DateTime.Now,
        CustomAppearance = new Aspose.Pdf.Forms.SignatureCustomAppearance
        {
            DigitalSignedLabel = "Firmado por ",
            DateSignedAtLabel = "Fecha ",
            FontSize = 6,
            FontFamilyName = "Arial",
            DateTimeFormat = "yyyy-MM-dd HH:mm:ss",
            ShowContactInfo = false,
            ShowLocation = false,
            ShowReason = false,                            
            Culture = System.Globalization.CultureInfo.InvariantCulture
            
        }
    };

    // Obtener dimensiones de la última página
    var tempDoc = new Aspose.Pdf.Document(ruta);
    int paginaFinal = tempDoc.Pages.Count;
    var rectPagina = tempDoc.Pages[paginaFinal].GetPageRect(true);
    float ancho = (float)rectPagina.Width * 0.40f;
    float alto = 30;
    float x = 20;
    float y = 20;

    System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)x, (int)y, (int)ancho, (int)alto);

    pdfFileSignature.Document.Info.Creator = "Prueba";
    pdfFileSignature.Document.Info.Producer = "Aspose.PDF";
    pdfFileSignature.Document.Info.Author = "Prueba";
    pdfFileSignature.Document.Metadata["xmp:CreatorTool"] = "Prueba";
    pdfFileSignature.Document.Metadata["pdf:Producer"] = "Aspose.PDF";

    pdfFileSignature.Sign(paginaFinal, true, rect, cert);
   pdfFileSignature.Save(rutaFirmado); //Ruta Firmado
}

Alguna sugerencia?

Gracias de antemano

@InformaticaAdarve

Confermate se la nostra comprensione è corretta. State firmando un PDF conforme al formato PDF/A e, durante la firma, la conformità al PDF/A fallisce con questi errori nel file log.xml. Nel caso in cui la nostra comprensione fosse errata, vi preghiamo di farcelo sapere. Inoltre, vi chiediamo di condividere un PDF di esempio e altri file PFX con noi, così da poter replicare il problema nel nostro ambiente e affrontarlo di conseguenza.

Hola @asad.ali

es correcto, al firmar se sobreescriben los metadatos lo que genera una no conformidad

lo que es peor aun es que ciertos casos, usando el mismo codigo, mismo cretificados, si queda bien y otras no.

trataré de generar un aislamiento de la falla tanto como pueda, pero lo principal es saber porque sobreescribe los metadatos akl firmar con
Aspose Pty Ltd.
Aspose.PDF for .NET 25.4.0

por ahora henotado alguna diferencia segun la plantilla original utilizada

como ya describí el proceso anteriormente:
1.- desde plantilla (.doc, .docx) realizo mailmerge (aspose.word), eso genera un pdf y se firma con aspose.pdf.facecades.sing, con el codigo que ya compartí

ya que tengo licencia aspose.total (.net) solo utilizo esas librerias

quedo pendiente de sus comentarios

Saludos

@InformaticaAdarve

Di solito, qualsiasi modifica a un documento PDF conforme a PDF/A ne revoca la conformità, quindi si può provare un approccio alternativo firmando prima e convertendo in PDF/A successivamente. Nel caso in cui anche questo non risolva il problema, fornire un set di file di esempio (PDF e PFX), sia funzionanti che non funzionanti. Registreremo un ticket di indagine nel nostro sistema di tracciamento dei problemi e condivideremo il relativo ID con voi.

la unica alerta que tengo es por la incongruencia en valor de 2 metadatos despues de firmar

El PDF/A esta OK
La Firma OK

Metadatos KO
xmp:CreatorTool: SometimeChange
pdf:Producer : SometimeChange
Info.Creator : Aspose Pty Ltd. <–AlwaysChange
Info.Producer : Aspose.PDF for .NET 25.4.0 <–AlwaysChange

<Compliance Name="Log" Operation="Validation" Target="PDF/A-1A">
<Version>1.0</Version>
<Copyright>Copyright (c) 2001-2025 Aspose Pty Ltd. All Rights Reserved.</Copyright>
<Date>01/08/2025 8:26:32</Date>
<File Version="1,7" Name="Escrito_456927_TY2025000063_20250801082631_F.pdf" Pages="1">
<Security/>
<Catalog/>
<Header/>
<Annotations/>
<Fonts/>
<trailer/>
<Metadata>
<Problem Severity="Error" Clause="6.7.3" Convertable="True">Document information entry 'Creator' not synchronized with metadata property 'xmp:CreatorTool'</Problem>
<Problem Severity="Error" Clause="6.7.3" Convertable="True">Document information entry 'Producer' not synchronized with metadata property 'pdf:Producer'</Problem>
</Metadata>
<objects/>
<xObjects/>
<actions/>
<xmpmeta/>
<EmbeddedFiles/>
</File>
</Compliance>

trataré de enviarles un set de plantillas, el pfx no será posible

@InformaticaAdarve

Certamente, inviate i file PDF di esempio. Utilizzeremo uno dei nostri file PFX di esempio per testare lo scenario e generare un ticket nel nostro sistema di tracciamento dei problemi per affrontarlo.