Package org.apache.pdfbox.pdmodel

Examples of org.apache.pdfbox.pdmodel.PDDocument.openProtection()


                    if( document.isEncrypted() )
                    {

                        StandardDecryptionMaterial spm = new StandardDecryptionMaterial(password);
                        document.openProtection(spm);
                        AccessPermission ap = document.getCurrentAccessPermission();


                        if( ! ap.canExtractContent() )
                        {
View Full Code Here


                    }
                    else
                    {
                        decryptionMaterial = new StandardDecryptionMaterial(password);
                    }
                    document.openProtection(decryptionMaterial);
                    AccessPermission ap = document.getCurrentAccessPermission();
                    if(ap.isOwnerPermission())
                    {
                        document.save( outfile );
                    }
View Full Code Here

        PDDocument encrypted = reload(document);
        try
        {
            Assert.assertTrue(encrypted.isEncrypted());
            encrypted.openProtection(decryption2);
            fail("No exception when using an incorrect decryption key");
        }
        catch(CryptographyException expected)
        {
            // do nothing
View Full Code Here

        PDDocument encrypted = reload(document);
        try
        {
            Assert.assertTrue(encrypted.isEncrypted());
            encrypted.openProtection(decryption1);

            AccessPermission permission =
                encrypted.getCurrentAccessPermission();
            Assert.assertFalse(permission.canAssembleDocument());
            Assert.assertFalse(permission.canExtractContent());
View Full Code Here

        // open first time
        PDDocument encrypted1 = reload(document);
        try
        {
            encrypted1.openProtection(decryption1);

            AccessPermission permission =
                encrypted1.getCurrentAccessPermission();
            Assert.assertFalse(permission.canAssembleDocument());
            Assert.assertFalse(permission.canExtractContent());
View Full Code Here

        // open second time
        PDDocument encrypted2 = reload(document);
        try
        {
            encrypted2.openProtection(decryption2);

            AccessPermission permission =
                encrypted2.getCurrentAccessPermission();
            Assert.assertFalse(permission.canAssembleDocument());
            Assert.assertFalse(permission.canExtractContent());
View Full Code Here

            Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
        }

        if (pdfDoc.isEncrypted()) {
            try {
                pdfDoc.openProtection(new StandardDecryptionMaterial(""));
            } catch (final BadSecurityHandlerException e) {
                try {pdfDoc.close();} catch (final IOException ee) {}
                throw new Parser.Failure("Document is encrypted (1): " + e.getMessage(), location);
            } catch (final IOException e) {
                try {pdfDoc.close();} catch (final IOException ee) {}
View Full Code Here

      stopProcessing("Time for loading: ", startTime);


      if (document.isEncrypted()) {
        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
        document.openProtection(sdm);
        AccessPermission ap = document.getCurrentAccessPermission();

        if (!ap.canExtractContent()) {
          throw new IOException("You do not have permission to extract text");
        }
View Full Code Here

                //document.print();
                if( document.isEncrypted() )
                {
                    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial( password );
                    document.openProtection( sdm );
                    AccessPermission ap = document.getCurrentAccessPermission();

                    if( ! ap.canExtractContent() )
                    {
                        throw new IOException( "You do not have permission to extract text" );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.