Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Apr 24, 2018 10:53 am

Hello,

In my case i need to load Certification data from usb certificate token, with x509Certificate2 i can get data from it
Code: Select all
 var page = docpdf.Pages[0];
            X509Store x509Store = new X509Store(StoreLocation.CurrentUser);
            x509Store.Open(OpenFlags.ReadOnly);

            byte[] test = Encoding.ASCII.GetBytes(docpdf.ToString());

            X509Certificate2Collection x509Certificate2Collection = x509Store.Certificates.Find(X509FindType.FindByIssuerName, "Baridesign", false);
            X509Certificate2 x509Certificate2 = x509Certificate2Collection[0];
 


But how can i do it with PdfCertificate ?

Thanks for your time!

walidrezzouqi
 
Posts: 6
Joined: Mon Apr 23, 2018 12:01 pm

Wed Apr 25, 2018 2:12 am

Hello,

Thanks for your post. You could transform the X509Certificate2 into PdfCertificate and use it directly. Please refer to the below code snippet. In addition, please use the latest version(Spire.PDF Pack(Hot Fix) Version:4.4.6).
Code: Select all
            PdfDocument pdfDocument = new PdfDocument();
            pdfDocument.LoadFromFile(@"C:\Users\Administrator\Desktop\1copy.pdf");
            var page = pdfDocument.Pages[0];

            X509Store x509Store = new X509Store(StoreLocation.CurrentUser);
            x509Store.Open(OpenFlags.ReadOnly);

            byte[] test = Encoding.ASCII.GetBytes(pdfDocument.ToString());

            X509Certificate2Collection x509Certificate2Collection = x509Store.Certificates.Find(X509FindType.FindByIssuerName, "Baridesign", false);

            X509Certificate2 x509Certificate2 = x509Certificate2Collection[0];
            PdfCertificate digi = x509Certificate2 as PdfCertificate;

            PdfSignature signature2 = new PdfSignature(pdfDocument, page, digi, "demo");
            signature2.ContactInfo = "Simon";
            signature2.Certificated = true;
            signature2.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
            signature2.Bounds = new RectangleF(new PointF(0, 0), new SizeF(200, 90));

            pdfDocument.SaveToFile("result.pdf",FileFormat.PDF);
            System.Diagnostics.Process.Start("result.pdf");


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Apr 25, 2018 9:44 am

Hello,

Thanks for your reply,

I will add it soon, and i will give you feedback.
I work on Qr-code right now to be implemented in the PDF generator

Walid.

walidrezzouqi
 
Posts: 6
Joined: Mon Apr 23, 2018 12:01 pm

Fri Apr 27, 2018 7:01 am

Hello,

How is it going?
Please give us some feedback at your convenience.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Fri Apr 27, 2018 9:49 am

Hello,

I make an update to use it, if i get un error i will tell you thanks.

Walid.

walidrezzouqi
 
Posts: 6
Joined: Mon Apr 23, 2018 12:01 pm

Return to Spire.PDF

cron