| Current Path : /var/www/html/mmishra/mm/ada/examples/ |
| Current File : /var/www/html/mmishra/mm/ada/examples/MetadataExtract.php |
<?php
# Check Windows operating system
function is_windows ( ) {
return ( substr_count( php_uname( 's' ), 'Windows' ) ? true : false ) ;
};
// Load VersyPDF extension
if (!extension_loaded('VersyPDF')) {
if ( is_windows() ) {
dl('php_versypdf.dll');
} else {
dl('versypdf.so');
}
}
// Initialise PDF Library with empty License name and key ( demo mode )
$Lib = pdf_library_init( "", "" );
// Launch destination PDF file after work if Windows Presents
if ( is_windows() ) {
$InputFile = getcwd().'\in\pdf\island.pdf';
$OutputFile = getcwd().'\out\other\metadata.out';
} else {
$InputFile = 'in/pdf/island.pdf';
$OutputFile = 'out/other/metadata.out';
}
$Doc = pdfdoc_load_from_file( $Lib, $InputFile );
$Root = pdfdoc_get_root( $Doc );
$Meta = cosdict_value_by_name( $Root, ul_atom_from_string( $Lib, 'Metadata' ) );
/* Check if "Metadata" stream object exists */
if ( cos_get_type( $Meta ) != COS_NULL ) {
$MetaAttr = cosstream_get_attr( $Meta );
$MetaStream = cosstream_get_value( $Meta );
if ( $MetaStream ) {
$OutStream = ul_stream_file_new( $Lib, $OutputFile, $$$PP_FILE_WRITEMODE );
ul_stream_copy_to_stream( $MetaStream, $OutStream );
ul_stream_close( $OutStream );
print "Success...\n";
}
} else {
print "No metadata...\n";
}
// Save destination pdf file as "draw_figures.pdf"
pdfdoc_close( $Doc );
// Free PDF Library
pdf_library_done( $Lib );
?>