public static void main ( String args [ ] ) { System . out . println ( "PDF document encryptor" ) ; if ( args . length <= STRENGTH || args [ PERMISSIONS ] . length ( ) != 8 ) { usage ( ) ; return ; } try { int permissions = 0 ; String p = args [ PERMISSIONS ] ; for ( int k = 0 ; k < p . length ( ) ; ++ k ) { permissions |= ( p . charAt ( k ) == ' ' ? 0 : permit [ k ] ) ; } System . out . println ( "Reading " + args [ INPUT_FILE ] ) ; PdfReader reader = new PdfReader ( args [ INPUT_FILE ] ) ; System . out . println ( "Writing " + args [ OUTPUT_FILE ] ) ; HashMap moreInfo = new HashMap ( ) ; for ( int k = MOREINFO ; k < args . length - 1 ; k += 2 ) moreInfo . put ( args [ k ] , args [ k + 1 ] ) ; PdfEncryptor . encrypt ( reader , new FileOutputStream ( args [ OUTPUT_FILE ] ) , args [ USER_PASSWORD ] . getBytes ( ) , args [ OWNER_PASSWORD ] . getBytes ( ) , permissions , args [ STRENGTH ] . equals ( "128" ) , moreInfo ) ; System . out . println ( "Done." ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } }
Encrypts a PDF document .