diff --git a/Annotation/Retrieve-review-status-from-the-existing-PDF-annotations/.NET/Program.cs b/Annotation/Retrieve-review-status-from-the-existing-PDF-annotations/.NET/Program.cs index ee806b90..635a9cb3 100644 --- a/Annotation/Retrieve-review-status-from-the-existing-PDF-annotations/.NET/Program.cs +++ b/Annotation/Retrieve-review-status-from-the-existing-PDF-annotations/.NET/Program.cs @@ -14,24 +14,23 @@ PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Get the annotation. -PdfLoadedRectangleAnnotation loadedMarkup = loadedPage.Annotations[0] as PdfLoadedRectangleAnnotation; +PdfLoadedRectangleAnnotation rectangleAnnotation = loadedPage.Annotations[0] as PdfLoadedRectangleAnnotation; //Get the review history collection for the annotation. -PdfLoadedPopupAnnotationCollection reviewCollection = loadedMarkup.ReviewHistory; - -//Get annotation state. -PdfAnnotationState state = reviewCollection[0].State; - -//Get annotation state model. -PdfAnnotationStateModel model = reviewCollection[0].StateModel; - -//Get the comments of the annotation. -PdfLoadedPopupAnnotationCollection commentsCollection = loadedMarkup.Comments; - -//Get the review history of the comment. -PdfLoadedPopupAnnotationCollection reviewCollection1 = commentsCollection[0].ReviewHistory; - -Console.WriteLine("Successfully retrive review status from PDF document"); +PdfLoadedPopupAnnotationCollection reviewCollection = rectangleAnnotation.ReviewHistory; + +//Iterate through the review history collection. +foreach (PdfLoadedPopupAnnotation review in reviewCollection) +{ + //Get the author of the annotation. + string author = review.Author; + //Get the state of the annotation. + PdfAnnotationState state = review.State; + //Get the state model of the annotation. + PdfAnnotationStateModel model = review.StateModel; + + Console.WriteLine("Author of the reviewer: " + author + "\r\nState: " + state + "\r\nState Model: " + model); +} //Closes the document. loadedDocument.Close(true); diff --git a/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Data/Input.pdf b/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Data/Input.pdf similarity index 100% rename from Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Data/Input.pdf rename to Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Data/Input.pdf diff --git a/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Program.cs b/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Program.cs similarity index 51% rename from Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Program.cs rename to Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Program.cs index ad78a358..926e8b65 100644 --- a/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Program.cs +++ b/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Program.cs @@ -4,6 +4,7 @@ using Syncfusion.Pdf.Interactive; using Syncfusion.Pdf.Parsing; +//Get stream from the existing PDF document. //Get stream from the existing PDF document. FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); @@ -14,12 +15,21 @@ PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; //Get the annotation. -PdfLoadedRectangleAnnotation loadedMarkup = loadedPage.Annotations[0] as PdfLoadedRectangleAnnotation; +PdfLoadedRectangleAnnotation rectangleAnnotation = loadedPage.Annotations[0] as PdfLoadedRectangleAnnotation; //Get the comments of the annotation. -PdfLoadedPopupAnnotationCollection commentsCollection = loadedMarkup.Comments; - -Console.WriteLine("Successfully retrive annotation comments from PDF document"); +PdfLoadedPopupAnnotationCollection commentsCollection = rectangleAnnotation.Comments; + +//Iterate through the comments collection. +foreach (PdfLoadedPopupAnnotation comment in commentsCollection) +{ + //Get the author of the comment. + string author = comment.Author; + //Get the content + string content = comment.Text; + + Console.WriteLine("Author of the comment: " + author + "\r\nContent: " + content); +} //Closes the document. loadedDocument.Close(true); diff --git a/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Retrieve-the-annotation-comments-from-the-existing-PDF.csproj b/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF.csproj similarity index 100% rename from Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF/Retrieve-the-annotation-comments-from-the-existing-PDF.csproj rename to Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF.csproj diff --git a/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF.sln b/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF.sln index 5210ae44..fbd4e532 100644 --- a/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF.sln +++ b/Annotation/Retrieve-the-annotation-comments-from-the-existing-PDF/.NET/Retrieve-the-annotation-comments-from-the-existing-PDF.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.1.32407.343 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retrieve-the-annotation-comments-from-the-existing-PDF", "Retrieve-the-annotation-comments-from-the-existing-PDF\Retrieve-the-annotation-comments-from-the-existing-PDF.csproj", "{D3C293E5-D34E-447F-99DD-DE563FFB9BA9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retrieve-the-annotation-comments-from-the-existing-PDF", "Retrieve-the-annotation-comments-from-the-existing-PDF.csproj", "{D3C293E5-D34E-447F-99DD-DE563FFB9BA9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Digital Signature/Customized-revocation-validation/.NET/Customized-revocation-validation/Program.cs b/Digital Signature/Customized-revocation-validation/.NET/Customized-revocation-validation/Program.cs index bee49330..6d175c5a 100644 --- a/Digital Signature/Customized-revocation-validation/.NET/Customized-revocation-validation/Program.cs +++ b/Digital Signature/Customized-revocation-validation/.NET/Customized-revocation-validation/Program.cs @@ -1,32 +1,33 @@ using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf.Security; - //Gets the stream from the document FileStream documentStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); //Loads an existing signed PDF document - PdfLoadedDocument document = new PdfLoadedDocument(documentStream); // Gets the signature field - PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField; // Signature validation options - PdfSignatureValidationOptions options = new PdfSignatureValidationOptions(); // Sets the revocation type - options.RevocationValidationType = RevocationValidationType.Crl; // Validate signature and get validation result - PdfSignatureValidationResult result = signatureField.ValidateSignature(options); -Console.WriteLine("Successfully validate customized revocation"); +//Check whether the CRL is revoked +if (result.RevocationResult.IsRevokedCRL) +{ + Console.WriteLine("CRL is revoked"); +} +else +{ + Console.WriteLine("CRL is not revoked"); +} // Closes the document - document.Close(true); \ No newline at end of file diff --git a/Digital Signature/Get-LTV-information/.NET/Get-LTV-information/Program.cs b/Digital Signature/Get-LTV-information/.NET/Get-LTV-information/Program.cs index dcd78904..3dc56429 100644 --- a/Digital Signature/Get-LTV-information/.NET/Get-LTV-information/Program.cs +++ b/Digital Signature/Get-LTV-information/.NET/Get-LTV-information/Program.cs @@ -1,45 +1,33 @@ - - -using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf.Security; //Gets the stream from the document FileStream documentStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); //Loads an existing signed PDF document - PdfLoadedDocument document = new PdfLoadedDocument(documentStream); // Gets the signature field - PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField; // Validates signature and get validation result - PdfSignatureValidationResult result = signatureField.ValidateSignature(); // Gets the LTV verification Information. - LtvVerificationInfo ltvVerificationInfo = result.LtvVerificationInfo; // Checks whether the signature document LTV is enabled. - 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); +Console.WriteLine("LTV enabled: " + isLtvEnabled); +Console.WriteLine("CRL embedded: " + isCrlEmbedded); +Console.WriteLine("OCSP embedded: " + isOcspEmbedded); // Closes the document - document.Close(true); \ No newline at end of file diff --git a/Digital Signature/Validate-all-signatures-in-digitally-signed-PDF/.NET/Validate-all-signatures-in-digitally-signed-PDF/Program.cs b/Digital Signature/Validate-all-signatures-in-digitally-signed-PDF/.NET/Validate-all-signatures-in-digitally-signed-PDF/Program.cs index e8776ae7..4facbdaa 100644 --- a/Digital Signature/Validate-all-signatures-in-digitally-signed-PDF/.NET/Validate-all-signatures-in-digitally-signed-PDF/Program.cs +++ b/Digital Signature/Validate-all-signatures-in-digitally-signed-PDF/.NET/Validate-all-signatures-in-digitally-signed-PDF/Program.cs @@ -28,7 +28,7 @@ List results; bool isValid = loadedDocument.Form.Fields.ValidateSignatures(collection, out results); -Console.WriteLine("Successfully validate all signatures in digitally signed PDF"); +Console.WriteLine("All signatures in the document are valid: " + isValid); //Close the document. loadedDocument.Close(true); diff --git a/Digital Signature/Validate-the-digitally-signed-PDF-signature/.NET/Validate-the-digitally-signed-PDF-signature/Program.cs b/Digital Signature/Validate-the-digitally-signed-PDF-signature/.NET/Validate-the-digitally-signed-PDF-signature/Program.cs index abac2b7e..0f3144d6 100644 --- a/Digital Signature/Validate-the-digitally-signed-PDF-signature/.NET/Validate-the-digitally-signed-PDF-signature/Program.cs +++ b/Digital Signature/Validate-the-digitally-signed-PDF-signature/.NET/Validate-the-digitally-signed-PDF-signature/Program.cs @@ -36,6 +36,8 @@ //Checks whether the document is modified or not. bool isModified = result.IsDocumentModified; +Console.WriteLine("Document modified: " + isModified); + //Signature details. string issuerName = signatureField.Signature.Certificate.IssuerName; DateTime validFrom = signatureField.Signature.Certificate.ValidFrom; @@ -43,12 +45,19 @@ string signatureAlgorithm = result.SignatureAlgorithm; DigestAlgorithm digestAlgorithm = result.DigestAlgorithm; +Console.WriteLine("Issuer Name: " + issuerName); +Console.WriteLine("Valid From: " + validFrom); +Console.WriteLine("Valid To: " + validTo); +Console.WriteLine("Signature Algorithm: " + signatureAlgorithm); +Console.WriteLine("Digest Algorithm: " + digestAlgorithm); + //Revocation validation details. RevocationResult revocationDetails = result.RevocationResult; RevocationStatus revocationStatus = revocationDetails.OcspRevocationStatus; bool isRevokedCRL = revocationDetails.IsRevokedCRL; -Console.WriteLine("Successfully validate all signatures in digitally signed PDF"); +Console.WriteLine("Revocation Status: " + revocationStatus); +Console.WriteLine("Is Revoked CRL: " + isRevokedCRL); //Close the document. loadedDocument.Close(true); diff --git a/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Load-an-encrypt-only-attachment-document.csproj b/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Load-an-encrypt-only-attachment-document.csproj index cd0aac2d..7771e5c7 100644 --- a/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Load-an-encrypt-only-attachment-document.csproj +++ b/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Load-an-encrypt-only-attachment-document.csproj @@ -16,6 +16,9 @@ Always + + Always + diff --git a/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Output/.gitkeep b/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Program.cs b/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Program.cs index f6ed1978..c3335fd4 100644 --- a/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Program.cs +++ b/Security/Load-an-encrypt-only-attachment-document/.NET/Load-an-encrypt-only-attachment-document/Program.cs @@ -12,12 +12,10 @@ //Accessing the attachments. foreach (PdfAttachment attachment in document.Attachments) { - FileStream stream = new FileStream(attachment.FileName, FileMode.Create); + FileStream stream = new FileStream(Path.GetFullPath(@"Output/") + attachment.FileName, FileMode.Create); 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); diff --git a/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Output/.gitkeep b/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Program.cs b/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Program.cs index fbae7222..0a3a2bd5 100644 --- a/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Program.cs +++ b/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Program.cs @@ -14,13 +14,12 @@ //Accessing the attachments. foreach (PdfAttachment attachment in document.Attachments) { - FileStream stream = new FileStream(attachment.FileName, FileMode.Create); + FileStream stream = new FileStream(Path.GetFullPath(@"Output/") + attachment.FileName, FileMode.Create); stream.Write(attachment.Data, 0, attachment.Data.Length); stream.Dispose(); } -Console.WriteLine("Successfully set user password when accessing the attachment"); //Close the document. document.Close(true); diff --git a/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Set-user-password-when-accessing-the-attachment.csproj b/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Set-user-password-when-accessing-the-attachment.csproj index 6ae6b085..fb1abc4d 100644 --- a/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Set-user-password-when-accessing-the-attachment.csproj +++ b/Security/Set-user-password-when-accessing-the-attachment/.NET/Set-user-password-when-accessing-the-attachment/Set-user-password-when-accessing-the-attachment.csproj @@ -16,6 +16,9 @@ Always + + Always + diff --git a/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Extract-ZUGFeRD-invoice-from-PDF-document.csproj b/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Extract-ZUGFeRD-invoice-from-PDF-document.csproj index 827fa16b..66ef0a66 100644 --- a/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Extract-ZUGFeRD-invoice-from-PDF-document.csproj +++ b/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Extract-ZUGFeRD-invoice-from-PDF-document.csproj @@ -16,6 +16,9 @@ Always + + Always + diff --git a/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Output/.gitkeep b/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Program.cs b/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Program.cs index 5b24f35c..2f5a0c98 100644 --- a/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Program.cs +++ b/ZUGFeRD/Extract-ZUGFeRD-invoice-from-PDF-document/.NET/Extract-ZUGFeRD-invoice-from-PDF-document/Program.cs @@ -13,10 +13,10 @@ foreach (PdfAttachment attachment in loadedDocument.Attachments) { //Extracts the ZUGFeRD invoice attachment and saves it to the disk. - FileStream s = new FileStream(attachment.FileName, FileMode.Create, FileAccess.Write); + FileStream s = new FileStream(Path.GetFullPath(@"Output/") + attachment.FileName, FileMode.Create, FileAccess.Write); 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);