public void SignAcroWithPageSignature() { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Sign.Resources.Sign.pdf", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, "Sign.pdf"); int left = 45; int top = 223; int width = 109; int height = 79; int page = 2; this.lockDocument = !this.lockDocument; FunctionDesigner designer = ProviderHelpers.CreateDesigner <SignProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); ConfigureSignCertificateProperties(designer, FileAuthentication.CertificateFile, this.lockDocument); designer.Properties[PropertyNames.Placement].Value = SignaturePosition.OnPage; designer.Properties[PropertyNames.PositionX].Value = left; designer.Properties[PropertyNames.PositionY].Value = top; designer.Properties[PropertyNames.Width].Value = width; designer.Properties[PropertyNames.Height].Value = height; designer.Properties[PropertyNames.Page].Value = page; designer.Properties[PropertyNames.BackgroundImage].Value = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Sign.Resources.Sign_Image.png", this.inputDirectory); designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <SignProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertPageSignature(outputFilePath, FileAuthentication.None, this.authenticationManager, signName, signLocation, signReason, this.lockDocument, page, Utilities.MillimetersToPoints(left), Utilities.MillimetersToPoints(top), Utilities.MillimetersToPoints(width), Utilities.MillimetersToPoints(height)); }
public void SignWithInvisibleSignature( [Values( FileAuthentication.None, FileAuthentication.Password /*, * Ignore: http://stackoverflow.com/questions/40045745/itextsharp-object-reference-error-on-pdfstamper-for-certificate-protected-file * FileAuthentication.CertificateFile, * FileAuthentication.CertificateStore*/)] FileAuthentication inputAuth, [Values( FileAuthentication.CertificateFile, FileAuthentication.CertificateStore)] FileAuthentication signAuth, [Values( "Sign.pdf", "SignXFA.pdf")] string fileName) { string inputFilePath = ResourceHelpers.WriteResourceToFile($"Twenty57.Linx.Components.Pdf.Tests.Sign.Resources.{fileName}", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, fileName); this.lockDocument = !this.lockDocument; FunctionDesigner designer = ProviderHelpers.CreateDesigner <SignProvider>(); ConfigureInputFileFunctionValues(designer, inputAuth, inputFilePath); ConfigureSignCertificateProperties(designer, signAuth, this.lockDocument); designer.Properties[PropertyNames.Placement].Value = SignaturePosition.Hidden; designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <SignProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertPageSignature(outputFilePath, inputAuth, this.authenticationManager, signName, signLocation, signReason, this.lockDocument, 1, 0, 0, 0, 0); }