true: multi-value, false: single-value $VALID_POST_PROCESSING_DIRECTIVES = array ( // VISIBILITY SPECIFICATION (ids lists) "only_first_page" => true, "only_last_page" => true, "all_but_first_page" => true, "all_but_last_page" => true, "only_even_page" => true, "only_odd_page" => true, // MARGIN (mm) "margin_left" => false, "margin_right" => false, "margin_top" => false, "margin_bottom" => false, // PAGE WIDTH (pixel) "page_width" => false ); /*****************************************************************************/ /** Run-time settings */ // ** PHP set_time_limit ( 10000 ); // ** HTML2PS ini_set ( "user_agent", DEFAULT_USER_AGENT ); $g_css_index = 0; $g_stylesheet_title = ""; // Title of styleshee to use (empty if no preferences are set) /*****************************************************************************/ /** Parameters */ // Input url $fi = trim ( urldecode ( get_var ( "fi", $_GET, 255, "" ) ) ); // Output file name (without ".pdf") $fo = trim ( urldecode ( get_var ( "fo", $_GET, 255, "document" ) ) ); // Margin value in mm (see page definition in test.html) $ml = (int) get_var ( "ml", $_GET, 255, -1 ); $mr = (int) get_var ( "mr", $_GET, 255, -1 ); $mt = (int) get_var ( "mt", $_GET, 255, -1 ); $mb = (int) get_var ( "mb", $_GET, 255, -1 ); // Page width $pw = (int) get_var ( "pw", $_GET, 255, -1 ); /*****************************************************************************/ /** Parameters validation */ if ( $fi == "" ) { die ( "Wrong parameters." ); } /*****************************************************************************/ /** Get post-processing information */ // *** Init global $POST_PROCESSING_DIRECTIVES; $POST_PROCESSING_DIRECTIVES = array(); // *** Get file content in row (array) $filerows = file ( $fi ); if ( $filerows == false ) { die ( "Unable to get file content." ); } // *** Search for directives block $viewed_post_process_open = false; $viewed_post_process_close = false; for ( $i = 0; $i < count ( $filerows ); $i++ ) { if ( strpos ( trim ( $filerows[$i] ), "HTML2PDF_POST_PROCESSING_DIRECTIVES -->" ) === 0 ) { // Directives block ended $viewed_post_process_close = true; break; } if ( $viewed_post_process_open ) { // Am i in directives lock? // Check if comment if ( strpos ( trim ( $filerows[$i] ), "//" ) === 0 ) { continue; } // Skip comment line // Normal line $tmp = explode ( ":", $filerows[$i] ); $row_type = ( isset ( $tmp[0] ) ? trim ( $tmp[0] ) : "" ); $row_info = ( isset ( $tmp[1] ) ? trim ( $tmp[1] ) : "" ); // This row is a valid directive? if ( ! isset ( $VALID_POST_PROCESSING_DIRECTIVES[$row_type] ) ) { die ( "Unknown POST PROCESSING directive: |$row_type|." ); } $mulval = $VALID_POST_PROCESSING_DIRECTIVES[$row_type]; // Save directive $values = explode ( ",", $row_info ); if ( $mulval ) { // Multi-value directive if ( count ( $values ) > 0 ) { if ( ! isset ( $POST_PROCESSING_DIRECTIVES[$row_type] ) ) { $POST_PROCESSING_DIRECTIVES[$row_type] = $values; } else { $POST_PROCESSING_DIRECTIVES[$row_type] = array_merge ( $POST_PROCESSING_DIRECTIVES[$row_type], $values ); } } } else { // Single-value directive if ( ! isset ( $values[0] ) ) { die ( "Specify a value for |$row_type| directive." ); } $POST_PROCESSING_DIRECTIVES[$row_type] = $values[0]; } } if ( strpos ( trim ( $filerows[$i] ), "