PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Using PDFSharp on C# Framework 3.5 or 4 (problems) https://forum.pdfsharp.net/viewtopic.php?f=2&t=4508 |
Page 1 of 1 |
Author: | elio.mota [ Tue Nov 14, 2023 10:35 am ] |
Post subject: | Using PDFSharp on C# Framework 3.5 or 4 (problems) |
Hi, I am trying to sign an PDF file using PDFSharp v.1.31 (to work on c# Framework 3.5 / 4). I create a simple project and i can do the "Hello world" sample without problems. Once i try to use it to sign an pdf file cames the problems, can some one get me on the track? 0 - I read that for older Frameworks i need to use the 1.31, am i wrong? 1 - Does the DPDFSharp 1.31 have the capabilities to sign pdf documents or need other version? (i could not be able to know it.. i already read the versions update and i thing that works!) 2 - the code that i am using, i get 2 different errors: 2.1 - X509Certificate2 could not be found --> (i used the System.Security.Cryptography.X509Certificates;) and it "worked" 2.1 - PdfSignatureField could not be found --> and this one i can not solve!! (what can i do?) 2.2 - PdfSignature could not be found --> (what can i do?) imports: using System; using System.Diagnostics; using System.IO; using PdfSharp; using PdfSharp.Drawing; using PdfSharp.Pdf; using PdfSharp.Pdf.IO; using System.Security.Cryptography.X509Certificates; CODE: PdfDocument document = PdfReader.Open(inputPdfPath, PdfDocumentOpenMode.Modify); // Load the certificate X509Certificate2 certificate = new X509Certificate2(certificatePath, certificatePassword); // Create a signature field PdfSignatureField signatureField = new PdfSignatureField(document.Pages[0], "SignatureField"); signatureField.Widget.Rect = new PdfSharp.Pdf.PdfRectangle(50, 50, 150, 80); document.AcroForm.Fields.Add(signatureField); // Create the signature PdfSignature signature = new PdfSignature(signatureField); signature.Certificate = certificate; signature.ContactInfo = "Your contact info"; signature.Location = "Location"; signature.Reason = "Reason for signing"; signature.DistinguishedName = certificate.Subject; // Save the document with the signature document.Save(outputPdfPath); I am new using PDFSharp, please thanks for help me!! |
Author: | TH-Soft [ Tue Nov 14, 2023 11:57 am ] |
Post subject: | Re: Using PDFSharp on C# Framework 3.5 or 4 (problems) |
elio.mota wrote: 0 - I read that for older Frameworks i need to use the 1.31, am i wrong? No link given. Any version up to 1.51 can be used.elio.mota wrote: 1 - Does the DPDFSharp 1.31 have the capabilities to sign pdf documents or need other version? (i could not be able to know it.. i already read the versions update and i thing that works!) Not "out of the box". Other people implemented signatures.
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |