socialtrio.blogg.se

Digitally sign pdf document
Digitally sign pdf document













digitally sign pdf document

Creates a new PDF document PdfDocument document = new PdfDocument () //Adds a new page PdfPageBase page = document. Close ( true ) //Defining the ContentType for pdf file string contentType = "application/pdf" //Define the file name string fileName = "Output.pdf" //Creates a FileContentResult object by using the file contents, content type, and file name return File ( stream, contentType, fileName ) Position = 0 //Close the documents document. DrawImage ( signatureImage, 0, 0 ) //Save the document into stream MemoryStream stream = new MemoryStream () document. Reason = "I am author of this document." //Draws the signature image graphics. LocationInfo = "Honolulu, Hawaii" signature. Bounds = new RectangleF ( new PointF ( 0, 0 ), signatureImage. Read ) //Sets an image for signature field PdfBitmap signatureImage = new PdfBitmap ( imageStream ) //Sets signature information signature. Read ) PdfCertificate pdfCert = new PdfCertificate ( certificateStream, "password123" ) //Creates a digital signature PdfSignature signature = new PdfSignature ( document, page, pdfCert, "Signature" ) //Sets an image for signature field FileStream imageStream = new FileStream ( "signature.jpg", FileMode. Graphics //Creates a certificate instance from PFX file with private key FileStream certificateStream = new FileStream ( "PDF.pfx", FileMode.

#Digitally sign pdf document code#

Refer to the PDF/UWP section for respective code samples Save ( stream, "Output.pdf" ) Close ( true ) //Save the stream as PDF document file in local machine. SaveAsync ( stream ) //Close the document document. DrawImage ( signatureImage, 0, 0 ) //Save the PDF document to stream MemoryStream stream = new MemoryStream () await document. GetManifestResourceStream ( ".jpg" ) PdfBitmap signatureImage = new PdfBitmap ( imageStream ) //Sets signature information signature. GetManifestResourceStream ( ".pfx" ) PdfCertificate pdfCert = new PdfCertificate ( certificateStream, "password123" ) //Creates a digital signature PdfSignature signature = new PdfSignature ( document, page, pdfCert, "Signature" ) //Sets an image for signature field Stream imageStream = typeof ( MainPage ). Graphics //Creates a certificate instance from PFX file with private key Stream certificateStream = typeof ( MainPage ).















Digitally sign pdf document