Esempio n. 1
0
        public void PdfVersion_IsDeterminedByPDFProcessor()
        {
            var profile = new ConversionProfile();

            _pdfProcessor.DeterminePdfVersion(profile).Returns("1.4 from PDFProcessor");
            var pdfTabViewModel = BuildViewModel();

            pdfTabViewModel.CurrentProfile = profile;

            Assert.AreEqual("1.4 from PDFProcessor", pdfTabViewModel.PdfVersion);
        }
Esempio n. 2
0
        public static void CheckPDFVersion(PdfReader pdfReader, ConversionProfile profile, IPdfProcessor pdfProcessor)
        {
            var expectedVersion = pdfProcessor.DeterminePdfVersion(profile);

            if (expectedVersion == "1.7")
            {
                Assert.AreEqual(PdfWriter.VERSION_1_7, pdfReader.PdfVersion, "Not PDF-Version 1.7");
            }
            else if (expectedVersion == "1.6")
            {
                Assert.AreEqual(PdfWriter.VERSION_1_6, pdfReader.PdfVersion, "Not PDF-Version 1.6");
            }
            else if (expectedVersion == "1.5")
            {
                Assert.AreEqual(PdfWriter.VERSION_1_5, pdfReader.PdfVersion, "Not PDF-Version 1.5");
            }
            else if (expectedVersion == "1.4")
            {
                Assert.AreEqual(PdfWriter.VERSION_1_4, pdfReader.PdfVersion, "Not PDF-Version 1.4");
            }
            else
            {
                Assert.AreEqual(PdfWriter.VERSION_1_3, pdfReader.PdfVersion, "Not PDF-Version 1.3");
            }
        }
Esempio n. 3
0
        public static string TestMultipleSigning(string testFile, ConversionProfile profile, JobPasswords passwords, IPdfProcessor pdfProcessor, Accounts accounts)
        {
            using (var pdfReader = BuildPdfReader(testFile, profile, passwords))
            {
                var doubleSignedFile = testFile.Replace(".pdf", "_doubleSignedFile.pdf");
                var fileStream       = new FileStream(doubleSignedFile, FileMode.Create, FileAccess.Write);
                var tempFile         = testFile.Replace(".pdf", "_tempFile.pdf");

                var intendedPdfVersion = pdfProcessor.DeterminePdfVersion(profile);
                var pdfVersion         = PdfWriter.VERSION_1_4;
                if (intendedPdfVersion == "1.5")
                {
                    pdfVersion = PdfWriter.VERSION_1_5;
                }
                else if (intendedPdfVersion == "1.6")
                {
                    pdfVersion = PdfWriter.VERSION_1_6;
                }
                else if (intendedPdfVersion == "1.7")
                {
                    pdfVersion = PdfWriter.VERSION_1_7;
                }

                //Create Stamper in append mode
                var stamper = PdfStamper.CreateSignature(pdfReader, fileStream, pdfVersion, tempFile, true);

                profile.PdfSettings.Signature.SignaturePage = SignaturePage.LastPage;
                var signer = new ITextSigner();
                signer.SignPdfFile(stamper, profile, passwords, accounts);

                stamper.Close();

                using (var doubleSignedPdfReader = BuildPdfReader(doubleSignedFile, profile, passwords))
                {
                    var af = doubleSignedPdfReader.AcroFields;

                    Assert.AreEqual(2, af.GetSignatureNames().Count, "Number of SignatureNames must be 2" + Environment.NewLine + "(" + testFile + ")");

                    //There is currently no way for testing multisigning.
                    //-> af.SignatureCoversWholeDocument(firstSignatureName) is always false, since a singature can't cover future signing
                    //-> firstSignature.Verify() returns always true.

                    /*
                     * var firstSignatureName = af.GetSignatureNames()[0];
                     * var firstSignature = af.VerifySignature(firstSignatureName);
                     *
                     * if (profile.PdfSettings.Signature.AllowMultiSigning)
                     * {
                     *  Assert.IsTrue(firstSignature.Verify(), "First signature is invalid altough multi signing was enabled");
                     * }
                     * else
                     * {
                     *  Assert.IsFalse(firstSignature.Verify(), "First signature is valid altough multi signing was disabled");
                     * }
                     * //*/

                    return(doubleSignedFile);
                }
            }
        }
Esempio n. 4
0
        private Conformance DeterminePdfVersionConformance(ConversionProfile profile)
        {
            var pdfVersion = _pdfProcessor.DeterminePdfVersion(profile);
            if (pdfVersion == "1.7")
                return Conformance.Pdf17;
            if (pdfVersion == "1.6")
                return Conformance.Pdf16;
            if (pdfVersion == "1.5")
                return Conformance.Pdf15;

            return Conformance.Pdf14;
        }
Esempio n. 5
0
        public void DeterminePdfVersion_DefaultVersionIs1_4()
        {
            var profile = new ConversionProfile();
            var version = _pdfProcessor.DeterminePdfVersion(profile);

            Assert.AreEqual("1.4", version, "Wrong PDFVersion");
        }
Esempio n. 6
0
        private Conformance DeterminePdfVersionConformance(ConversionProfile profile)
        {
            var pdfVersion = _pdfProcessor.DeterminePdfVersion(profile);

            if (pdfVersion == "1.7")
            {
                return(Conformance.Pdf17);
            }
            if (pdfVersion == "1.6")
            {
                return(Conformance.Pdf16);
            }
            if (pdfVersion == "1.5")
            {
                return(Conformance.Pdf15);
            }
            if (pdfVersion == "1.4")
            {
                return(Conformance.Pdf14);
            }

            return(Conformance.Pdf13);
        }