예제 #1
0
        public void PdfVersionTest_DefaultProfile_VersionIs4()
        {
            var profile = new ConversionProfile();
            var version = PDFProcessor.DeterminePdfVersion(profile);

            Assert.AreEqual("1.4", version, "Wrong PDFVersion for default Profile");
        }
예제 #2
0
        public void TestUnavailableTimeServer()
        {
            _th.Job.Profile.PdfSettings.Signature.AllowMultiSigning          = false;
            _th.Job.Profile.PdfSettings.Signature.DisplaySignatureInDocument = true;
            _th.Job.Profile.PdfSettings.Signature.SignaturePage       = SignaturePage.CustomPage;
            _th.Job.Profile.PdfSettings.Signature.SignatureCustomPage = 5;
            _th.Job.Profile.PdfSettings.Signature.LeftX         = 100;
            _th.Job.Profile.PdfSettings.Signature.LeftY         = 20;
            _th.Job.Profile.PdfSettings.Signature.RightX        = 200;
            _th.Job.Profile.PdfSettings.Signature.RightY        = 40;
            _th.Job.Profile.PdfSettings.Signature.SignContact   = "Mr.Test";
            _th.Job.Profile.PdfSettings.Signature.SignLocation  = "Testland";
            _th.Job.Profile.PdfSettings.Signature.SignReason    = "The Reason is Testing";
            _th.Job.Profile.PdfSettings.Signature.TimeServerUrl = "http://timestamp.123456.hopefully.never.exists.123456.globalsign.com/scripts/timestamp.dll";

            try
            {
                PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);
            }
            catch (ProcessingException pEx)
            {
                Assert.AreEqual(12205, pEx.ErrorCode, "Wrong error code for unavailable time server");
                return;
            }

            Assert.Fail("Did not throw ProcessingException for unavailable time server");
        }
예제 #3
0
        public void TestingWithJob_CheckIfFileExistsAndTempFilesAreDeleted_AllPdfPropertiesDisabled()
        {
            _th.Profile.OutputFormat = OutputFormat.Pdf; //UpdateXMPMetadata enabled if format is not PDF/A
            _th.Profile.PdfSettings.Security.Enabled  = false;
            _th.Profile.PdfSettings.Signature.Enabled = false;
            _th.Profile.BackgroundPage.Enabled        = false;

            _th.GenerateGsJob_WithSettedOutput(TestFile.PDFCreatorTestpagePDF);
            File.Delete(_th.TmpInfFile);
            foreach (string psFile in _th.TmpPsFiles)
            {
                File.Delete(psFile);
            }

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            foreach (string file in _th.Job.OutputFiles)
            {
                Assert.IsTrue(File.Exists(file), "File does not exist after processing: " + file);
                File.Delete(file);
            }

            var files = Directory.GetFiles(_th.TmpTestFolder);

            Assert.IsEmpty(files, "TmpTestFolder should be empty, after deleting processed file, but contained: "
                           + Environment.NewLine + files);
        }
예제 #4
0
        private void TestEncryption()
        {
            PDFProcessor.ProcessPDF(_testFile, _th.Profile, _passwords);

            EncryptionTester.MakePasswordTest(_testFile, _th.Profile, _passwords);
            EncryptionTester.MakeSecurityTest(_testFile, _th.Profile, _passwords.PdfOwnerPassword);
        }
예제 #5
0
 public void DenyProcessingForPng_with_Encryption_Backgroundpage_Singing()
 {
     _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.Png);
     _th.Job.Profile.PdfSettings.Security.Enabled  = true;
     _th.Job.Profile.BackgroundPage.Enabled        = true;
     _th.Job.Profile.PdfSettings.Signature.Enabled = true;
     Assert.IsFalse(PDFProcessor.ProcessingRequired(_th.Job.Profile));
 }
예제 #6
0
        private void ProcessOutput()
        {
            if (!PDFProcessor.ProcessingRequired(Profile))
            {
                return;
            }

            PDFProcessor.ProcessPDF(TempOutputFiles[0], Profile, Passwords);
        }
예제 #7
0
        public void Signing_ExpiredLicense_ThrowsException()
        {
            TestHelper.Job.Profile.OutputFormat = OutputFormat.Pdf;
            TestHelper.Job.Profile.PdfSettings.Signature.CertificateFile = TestHelper.GenerateTestFile(TestFile.CertificationFile_ExpiredP12);

            var ex = Assert.Throws <ProcessingException>(() => PDFProcessor.ProcessPdf(TestHelper.Job));

            Assert.AreEqual(ErrorCode.Signature_Invalid, ex.ErrorCode, "Wrong error code for expired certificate/signature");
        }
예제 #8
0
        public void PdfVersionTest_ProfileWith_EnabledSecurityAnd128AesLevel_VersionIs6()
        {
            var profile = new ConversionProfile();

            profile.PdfSettings.Security.Enabled         = true;
            profile.PdfSettings.Security.EncryptionLevel = EncryptionLevel.Aes128Bit;
            var version = PDFProcessor.DeterminePdfVersion(profile);

            Assert.AreEqual("1.6", version, "Wrong PDFVersion for enabled security with Aes128Bit");
        }
예제 #9
0
        public void MetadataAndSigning()
        {
            _th.Job.Profile.OutputFormat = OutputFormat.PdfA2B; //Enables pdf metadata update
            _th.Job.Profile.PdfSettings.Security.Enabled  = false;
            _th.Job.Profile.PdfSettings.Signature.Enabled = true;
            _th.Job.Profile.BackgroundPage.Enabled        = false;

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            XmpMetadataTester.CheckForXMPMetadataUpdateStrings(_th.Job);
            SigningTester.TestSignature(_th.Job);
        }
예제 #10
0
        public void EncryptionAndSigning()
        {
            _th.Job.Profile.OutputFormat = OutputFormat.Pdf; //Disables pdf metadata update
            _th.Job.Profile.PdfSettings.Security.Enabled  = true;
            _th.Job.Profile.PdfSettings.Signature.Enabled = true;
            _th.Job.Profile.BackgroundPage.Enabled        = false;

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            EncryptionTester.MakeSecurityTest(_th.Job);
            SigningTester.TestSignature(_th.Job);
        }
예제 #11
0
        public void MetadataEncryptionAndBackground()
        {
            _th.Job.Profile.OutputFormat = OutputFormat.PdfA2B; //Enables pdf metadata update
            _th.Job.Profile.PdfSettings.Security.Enabled  = true;
            _th.Job.Profile.PdfSettings.Signature.Enabled = false;
            _th.Job.Profile.BackgroundPage.Enabled        = true;

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            XmpMetadataTester.CheckForXMPMetadataUpdateStrings(_th.Job);
            EncryptionTester.MakeSecurityTest(_th.Job);
            BackgroundPageTester.BackgroundOnPage(_th.Job);
        }
예제 #12
0
        /// <summary>
        /// Determine number of pages in attachment file
        /// </summary>
        /// <returns>Number of pages in attachment file</returns>
        private int GetNumberOfAttachmentPages()
        {
            var count = 0;

            if (Profile.AttachmentPage.Enabled)
            {
                try
                {
                    count += PDFProcessor.GetNumberOfPages(Profile.AttachmentPage.File);
                }
                catch
                {
                    Logger.Warn("Problem detecting page number of attachment page file \"" + Profile.AttachmentPage.File + "\"");
                    count = 1;
                }
            }
            return(count);
        }
예제 #13
0
        /*
         * private PrintManager printMan;
         * private PrintDocument printDoc;
         * private IPrintDocumentSource printDocSource;
         */
        public ExportPrint()
        {
            this.InitializeComponent();
            pdfp = new PDFProcessor();
            //init listbox

            /*
             * if (origin == "Recipe")
             * {
             *  listBox_shoppingList.ItemsSource = controller.recipeList;
             *  listBox_shoppingList.DisplayMemberPath = "title";
             * }
             * else if (origin == "Shopping")
             * {
             *  listBox_shoppingList.ItemsSource = controller.shoppingList;
             *  listBox_shoppingList.DisplayMemberPath = "date";
             * }*/
        }
예제 #14
0
        public void TestSigningCustomPageGreaterThanNumberOfPages()
        {
            _th.Job.Profile.PdfSettings.Signature.AllowMultiSigning          = false;
            _th.Job.Profile.PdfSettings.Signature.DisplaySignatureInDocument = true;
            _th.Job.Profile.PdfSettings.Signature.SignaturePage       = SignaturePage.CustomPage;
            _th.Job.Profile.PdfSettings.Signature.SignatureCustomPage = 5;
            _th.Job.Profile.PdfSettings.Signature.LeftX         = 100;
            _th.Job.Profile.PdfSettings.Signature.LeftY         = 20;
            _th.Job.Profile.PdfSettings.Signature.RightX        = 200;
            _th.Job.Profile.PdfSettings.Signature.RightY        = 40;
            _th.Job.Profile.PdfSettings.Signature.SignContact   = "Mr.Test";
            _th.Job.Profile.PdfSettings.Signature.SignLocation  = "Testland";
            _th.Job.Profile.PdfSettings.Signature.SignReason    = "The Reason is Testing";
            _th.Job.Profile.PdfSettings.Signature.TimeServerUrl = "http://timestamp.globalsign.com/scripts/timestamp.dll";

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            SigningTester.TestSignature(_th.Job);
        }
예제 #15
0
        public void TestSigningCustomPageSpecialCharacters()
        {
            _th.Job.Profile.PdfSettings.Signature.AllowMultiSigning          = false;
            _th.Job.Profile.PdfSettings.Signature.DisplaySignatureInDocument = true;
            _th.Job.Profile.PdfSettings.Signature.SignaturePage       = SignaturePage.CustomPage;
            _th.Job.Profile.PdfSettings.Signature.SignatureCustomPage = 2;
            _th.Job.Profile.PdfSettings.Signature.LeftX         = 1000;
            _th.Job.Profile.PdfSettings.Signature.LeftY         = 200;
            _th.Job.Profile.PdfSettings.Signature.RightX        = 2000;
            _th.Job.Profile.PdfSettings.Signature.RightY        = 400;
            _th.Job.Profile.PdfSettings.Signature.SignContact   = "^^ Mr.Täst ^^";
            _th.Job.Profile.PdfSettings.Signature.SignLocation  = "Tästlènd";
            _th.Job.Profile.PdfSettings.Signature.SignReason    = "The Réßön is Tästing";
            _th.Job.Profile.PdfSettings.Signature.TimeServerUrl = "http://timestamp.globalsign.com/scripts/timestamp.dll";

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            SigningTester.TestSignature(_th.Job);
        }
예제 #16
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            if (txPDFFileName.Text.Trim() != "" &&
                File.Exists(txPDFFileName.Text))
            {
                try
                {
                    Cursor = Cursors.WaitCursor;

                    var textExtractor = new PDFTextReader.PDFTextReader();
                    var list          = textExtractor.GetText(txPDFFileName.Text);

                    var textFolder = $"{txOutFolder.Text}\\{Path.GetFileNameWithoutExtension(txPDFFileName.Text)}\\Text";
                    if (!Directory.Exists(textFolder))
                    {
                        Directory.CreateDirectory(textFolder);
                    }


                    for (int i = 0; i < list.Count; i++)
                    {
                        string fileName = $"{textFolder}\\Text_Page_{i.ToString().PadLeft(4, '0')}.txt";
                        File.WriteAllText(fileName, list[i]);
                    }
                    ;


                    var imageExtractor = new PDFProcessor();
                    imageExtractor.exportImages(txPDFFileName.Text, txOutFolder.Text);

                    MessageBox.Show("process finished SUCCESFULLY. Check Folder");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Processing file", ex.Message);
                }
                Cursor = Cursors.Default;
            }
            else
            {
                MessageBox.Show("Select an existing PDF File, and a output folder");
            }
        }
예제 #17
0
        public void CheckIfFileExistsAndTempFilesAreDeleted_AllPdfPropertiesDisabled()
        {
            var pdfFile = _th.GenerateTestFile(TestFile.PDFCreatorTestpagePDF);

            var profile = new ConversionProfile();

            profile.OutputFormat = OutputFormat.Pdf;
            //UpdateXMPMetadata enabled if format is not PDF/A
            profile.PdfSettings.Security.Enabled  = false;
            profile.PdfSettings.Signature.Enabled = false;
            profile.BackgroundPage.Enabled        = false;

            var jobPasswords = new JobPasswords();

            PDFProcessor.ProcessPDF(pdfFile, profile, jobPasswords);

            Assert.IsTrue(File.Exists(pdfFile), "Processed file does not exist.");
            File.Delete(pdfFile);
            var files = Directory.GetFiles(_th.TmpTestFolder);

            Assert.IsEmpty(files, "TmpTestFolder should be empty, after deleting processed file, but contained: "
                           + Environment.NewLine + files);
        }
예제 #18
0
        public void TestSigning_SecuredTimeServerEnabled_TimeserverDoesNotRequireLogin()
        {
            _th.Job.Profile.PdfSettings.Signature.AllowMultiSigning          = false;
            _th.Job.Profile.PdfSettings.Signature.DisplaySignatureInDocument = true;
            _th.Job.Profile.PdfSettings.Signature.SignaturePage       = SignaturePage.CustomPage;
            _th.Job.Profile.PdfSettings.Signature.SignatureCustomPage = 1;
            _th.Job.Profile.PdfSettings.Signature.LeftX         = 100;
            _th.Job.Profile.PdfSettings.Signature.LeftY         = 20;
            _th.Job.Profile.PdfSettings.Signature.RightX        = 200;
            _th.Job.Profile.PdfSettings.Signature.RightY        = 40;
            _th.Job.Profile.PdfSettings.Signature.SignContact   = "Mr.Test";
            _th.Job.Profile.PdfSettings.Signature.SignLocation  = "Testland";
            _th.Job.Profile.PdfSettings.Signature.SignReason    = "The Reason is Testing";
            _th.Job.Profile.PdfSettings.Signature.TimeServerUrl = "http://timestamp.globalsign.com/scripts/timestamp.dll";

            _th.Job.Profile.PdfSettings.Signature.TimeServerIsSecured = true;
            _th.Job.Profile.PdfSettings.Signature.TimeServerLoginName = "TimeServerLoginName";
            _th.Job.Profile.PdfSettings.Signature.TimeServerPassword  = "******";

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            SigningTester.TestSignature(_th.Job);
        }
예제 #19
0
        public void TwoSignatures_MultisigningIsEnabled_BothSignatuesAreValid()
        {
            _th.Job.Profile.PdfSettings.Signature.AllowMultiSigning = true;

            _th.Job.Profile.PdfSettings.Signature.DisplaySignatureInDocument = true;
            _th.Job.Profile.PdfSettings.Signature.SignaturePage       = SignaturePage.FirstPage;
            _th.Job.Profile.PdfSettings.Signature.SignatureCustomPage = 2;
            _th.Job.Profile.PdfSettings.Signature.LeftX         = 300;
            _th.Job.Profile.PdfSettings.Signature.LeftY         = 200;
            _th.Job.Profile.PdfSettings.Signature.RightX        = 500;
            _th.Job.Profile.PdfSettings.Signature.RightY        = 400;
            _th.Job.Profile.PdfSettings.Signature.SignContact   = "Mr.Test";
            _th.Job.Profile.PdfSettings.Signature.SignLocation  = "Testland";
            _th.Job.Profile.PdfSettings.Signature.SignReason    = "The Reason is Testing";
            _th.Job.Profile.PdfSettings.Signature.TimeServerUrl = "http://timestamp.globalsign.com/scripts/timestamp.dll";
            _th.Job.Profile.PdfSettings.Security.Enabled        = false;

            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);
            _th.Job.Profile.PdfSettings.Signature.SignaturePage = SignaturePage.LastPage;
            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            SigningTester.TestSignature(_th.Job, 2, true);
        }
예제 #20
0
        public void CheckForXMPMetadataUpdateStrings()
        {
            PDFProcessor.ProcessPDF(_th.Job.OutputFiles[0], _th.Job.Profile, _th.Job.Passwords);

            XmpMetadataTester.CheckForXMPMetadataUpdateStrings(_th.Job);
        }
예제 #21
0
 public void RequireProcessingForPDF_with_Backgroundpage()
 {
     _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.PdfX);
     _th.Job.Profile.BackgroundPage.Enabled = true;
     Assert.IsTrue(PDFProcessor.ProcessingRequired(_th.Job.Profile));
 }
예제 #22
0
 public void RequireProcessingForPdfX_with_Encryption()
 {
     _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.PdfX);
     _th.Job.Profile.PdfSettings.Security.Enabled = true;
     Assert.IsTrue(PDFProcessor.ProcessingRequired(_th.Job.Profile));
 }
예제 #23
0
 public void RequireProcessingForPDF_with_Signing()
 {
     _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.Pdf);
     _th.Job.Profile.PdfSettings.Signature.Enabled = true;
     Assert.IsTrue(PDFProcessor.ProcessingRequired(_th.Job.Profile));
 }