Our PDFs has two signatures: one invisible and one with picture.
- With 9.2.0 version there was no problem, after the signaturing we saw both of them. (see pic "Signed (good)")
- But in the new version - we saw only one signature (there is no "invisible" signature in the PDF (see pic "Signed (error)")
Could you check it?
Thanks:
Attila Farkas
The source:
- Code: Select all
string input = @"c:\temp\teszt.pdf ";
string pfx = @"c:\temp\pdf_poc.pfx";
string icon = @"c:\temp\logo.png";
string output = @"c:\\temp\\teszt_alairt.pdf ";
Spire.Pdf.License.LicenseProvider.SetLicenseKey(RendszerBeallitasok.SpireLicence);
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(input);
PdfCertificate cert = new PdfCertificate(pfx, "alma");
// Visible signatue
Spire.Pdf.Security.PdfSignature signature = new Spire.Pdf.Security.PdfSignature(doc, doc.Pages[0], cert, "signature0");
signature.Bounds = new RectangleF(new PointF(90, 550), new SizeF(270, 90));
//Load sign image source.
signature.SignImageSource = PdfImage.FromFile(icon);
//Set the dispay mode of graphics, if not set any, the default one will be applied
signature.GraphicsMode = Spire.Pdf.Security.GraphicMode.SignImageAndSignDetail;
signature.NameLabel = "Signer:";
signature.Name = "Gary";
signature.ContactInfoLabel = "ContactInfo:";
signature.ContactInfo = signature.Certificate.GetNameInfo(System.Security.Cryptography.X509Certificates.X509NameType.SimpleName, true);
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "Chengdu";
signature.ReasonLabel = "Reason: ";
signature.Reason = "The certificate of this document";
signature.DistinguishedNameLabel = "DN: ";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
signature.Certificated = true;
//Set fonts. if not set, default ones will be applied.
signature.SignDetailsFont = new PdfFont(PdfFontFamily.TimesRoman, 10f);
signature.SignNameFont = new PdfFont(PdfFontFamily.Courier, 15);
//Set the sign image layout mode
signature.SignImageLayout = Spire.Pdf.Security.SignImageLayout.None;
// InVisible signatue
PdfCertificate cert2 = new PdfCertificate(pfx, "alma");
//Create a PdfSignature object
Spire.Pdf.Security.PdfSignature signature2 = new Spire.Pdf.Security.PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "MySignature");
//Set the document permission to forbid changes but allow form fill
signature2.DocumentPermissions = PdfCertificationFlags.ForbidChanges | PdfCertificationFlags.AllowFormFill;
//Save pdf file.
doc.SaveToFile(output);
doc.Close();