Skip to content

Commit

Permalink
Playground_sample: Updated the github sample for playground integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sri-hari-haran-g committed Aug 26, 2024
1 parent 20bd77c commit 04e180e
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
//Get the review history of the comment.
PdfLoadedPopupAnnotationCollection reviewCollection1 = commentsCollection[0].ReviewHistory;

Console.WriteLine("Successfully retrive review status from PDF document");

//Closes the document.
loadedDocument.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
//Get the comments of the annotation.
PdfLoadedPopupAnnotationCollection commentsCollection = loadedMarkup.Comments;

Console.WriteLine("Successfully retrive annotation comments from PDF document");

//Closes the document.
loadedDocument.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

PdfSignatureValidationResult result = signatureField.ValidateSignature(options);

Console.WriteLine("Successfully validate customized revocation");

// Closes the document

document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@

bool isLtvEnabled = ltvVerificationInfo.IsLtvEnabled;

Console.WriteLine("isLtvEnabled :" + isLtvEnabled);

// Checks whether the signature document has CRL embedded.

bool isCrlEmbedded = ltvVerificationInfo.IsCrlEmbedded;

Console.WriteLine("isCrlEmbedded :" + isCrlEmbedded);

// Checks whether the signature document has OCSP embedded.

bool isOcspEmbedded = ltvVerificationInfo.IsOcspEmbedded;

Console.WriteLine("isOcspEmbedded :" + isOcspEmbedded);

// Closes the document

document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Security.Cryptography.X509Certificates;

//Load a PDF document
FileStream docStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read);
FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read);
PdfLoadedDocument document = new PdfLoadedDocument(docStream);
//Gets the signature field.
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Security.Cryptography.X509Certificates;

//Gets the stream from the document
FileStream documentStream = new FileStream(@"Data/DigitalSignature.pdf", FileMode.Open, FileAccess.Read);
FileStream documentStream = new FileStream(Path.GetFullPath(@"Data/DigitalSignature.pdf"), FileMode.Open, FileAccess.Read);
//Load an existing signed PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(documentStream);

Expand All @@ -14,11 +14,11 @@
//X509Certificate2Collection to check the signer's identity using root certificates.
X509CertificateCollection collection = new X509CertificateCollection();
//Create new X509Certificate2 with the root certificate.
X509Certificate2 certificate = new X509Certificate2(@"Data/Root.cer");
X509Certificate2 certificate = new X509Certificate2(Path.GetFullPath(@"Data/Root.cer"));
//Add the certificate to the collection.
collection.Add(certificate);
//Create new X509Certificate2 with the intermediate certificate.
certificate = new X509Certificate2(@"Data/Intermediate0.cer");
certificate = new X509Certificate2(Path.GetFullPath(@"Data/Intermediate0.cer"));
//Add the certificate to the collection.
collection.Add(certificate);
//Validate signature and get the validation result
Expand All @@ -31,6 +31,7 @@
foreach (X509Certificate2 item in signerCertificate.OcspCertificate.Certificates)
{
string subjectName = "The OCSP Response was signed by " + item.SubjectName.Name;
Console.WriteLine(subjectName);
}
bool isEmbbed = signerCertificate.OcspCertificate.IsEmbedded;
DateTime validForm = signerCertificate.OcspCertificate.ValidFrom;
Expand All @@ -41,6 +42,7 @@
foreach (X509Certificate2 item in signerCertificate.CrlCertificate.Certificates)
{
string subjectName = "The CRL was signed by " + item.SubjectName.Name;
Console.WriteLine(subjectName);
}
bool isEmbbed = signerCertificate.CrlCertificate.IsEmbedded;
DateTime validForm = signerCertificate.CrlCertificate.ValidFrom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Syncfusion.Pdf.Parsing;

//Loads an existing document
FileStream docStream = new FileStream(@"Data/Input.pdf", FileMode.Open, FileAccess.Read);
FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read);
PdfLoadedDocument document = new PdfLoadedDocument(docStream);

//Gets an array of revisions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
List<PdfSignatureValidationResult> results;
bool isValid = loadedDocument.Form.Fields.ValidateSignatures(collection, out results);

Console.WriteLine("Successfully validate all signatures in digitally signed PDF");

//Close the document.
loadedDocument.Close(true);


Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@
RevocationStatus revocationStatus = revocationDetails.OcspRevocationStatus;
bool isRevokedCRL = revocationDetails.IsRevokedCRL;

Console.WriteLine("Successfully validate all signatures in digitally signed PDF");

//Close the document.
loadedDocument.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
//Get the conformance level of the loaded document.
PdfConformanceLevel conformance = loadedDocument.Conformance;

Console.WriteLine("Conformance level :" + conformance);

//Close the document.
loadedDocument.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
stream.Write(attachment.Data, 0, attachment.Data.Length);
stream.Dispose();
}


Console.WriteLine("Successfully loaded an encrypt only attachment document");

//Close the document.
document.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

stream.Dispose();
}
Console.WriteLine("Successfully set user password when accessing the attachment");

//Close the document.
document.Close(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
s.Write(attachment.Data, 0, attachment.Data.Length);
s.Dispose();
}

Console.WriteLine("Successfully extract ZUGFeRD invoice from PDF document");
//Close the PDF document.
loadedDocument.Close(true);

0 comments on commit 04e180e

Please sign in to comment.