| Current Path : /var/www/html/mmishra/mm/ada/examples/ |
| Current File : /var/www/html/mmishra/mm/ada/examples/Password.php |
<?php
//********************************************************************
//
// SYBREX SYSTEMS INCORPORATED
// Copyright (C) 2005 Sybrex Systems Incorporated
// All rights reserved.
//
// NOTICE: Sybrex permits you to use, modify, and distribute this file
// in accordance with the terms of the Sybrex license agreement
// accompanying it. If you have received this file from a source other
// than Sybrex, then your use, modification, or distribution of it
// requires the prior written permission of Sybrex.
//----------------------------------------------------------------------
// Password.php
//*********************************************************************
// Check Windows operating system
function is_windows() {
return ( substr_count( php_uname( 's' ) , 'Windows' ) ? true : false );
}
if ( is_windows() ) {
$FileName = getcwd().'\in\pdf\island.pdf';
} else {
$FileName = 'in/pdf/island.pdf';
}
if (!extension_loaded('VersyPDF')) {
if ( is_windows() ) {
dl('php_versypdf.dll');
} else {
dl('versypdf.so');
}
}
// Initialize PDF Library with empty license name and key ( Demo version )
$Lib = pdf_library_init( "", "" );
// Variable $all define all permission for user and owner
$all = PR_PRINT | PR_MODIFY_CONTENT | PR_COPY_INFORMATION | PR_MODIFY_ANNOTATION | PR_FILL_ACROFORM | PR_EXTRACT_TEXTANDIMAGE | PR_ASSEMBLE_DOCUMENT | PR_PRINT_HIRESOLUTION;
// Load existing PDF file
$Doc = pdfdoc_load_from_file( $Lib, $FileName );
// Set non-linearize option for crypted PDF file
pdfdoc_set_linearized( $Doc, false );
// Launch destination PDF file after work if Windows OS presents
if ( is_windows() ) pdfdoc_set_auto_launch( $Doc, true );
// Set security on pdf-file with all permissions, 128-bits crypt key and passwords
// user - "123", owner - "12345"
pdfdoc_set_security( $Doc, $all, PT_128BIT_PROTECTION, '123', '12345' );
// Save the Document
$SapiName = php_sapi_name();
if ( $SapiName != 'cli' ) {
$Mem = pdfdoc_save_to_buffer( $Doc, &$Size );
header( "Content-Disposition: inline; filename = Password.pdf", true );
header( "Content-Type: application/pdf", true );
header( "Content-Length: $Size", true );
echo( $Mem );
} else {
pdfdoc_save_to_file( $Doc, "out/pdf/Password.pdf" );
print "Success...\n";
}
// Close PDF Document and free memory
pdfdoc_close( $Doc );
// Free PDF Library
pdf_library_done( $Lib );
?>