$opt_settings->SetGrayScaleImageSettings($image_settings); // use the same settings for both color and grayscale images Optimizer::Optimize($doc, $opt_settings); $doc->Save($output_path . $input_filename . "_opt2.pdf", SDFDoc::e_linearized); $doc->Close(); //-------------------------------------------------------------------------------- // Example 3) Use monochrome image settings and default settings // for color and grayscale images. $doc = new PDFDoc($input_path . $input_filename . ".pdf"); $doc->InitSecurityHandler(); $mono_image_settings = new MonoImageSettings(); $mono_image_settings->SetCompressionMode(MonoImageSettings::e_jbig2); $mono_image_settings->ForceRecompression(true); $opt_settings = new OptimizerSettings(); $opt_settings->SetMonoImageSettings($mono_image_settings); Optimizer::Optimize($doc, $opt_settings); $doc->Save($output_path . $input_filename . "_opt3.pdf", SDFDoc::e_linearized); $doc->Close(); // ---------------------------------------------------------------------- // Example 4) Use Flattener to simplify content in this document // using default settings $doc = new PDFDoc($input_path . "TigerText.pdf"); $doc->InitSecurityHandler(); $fl = new Flattener(); // The following lines can increase the resolution of background // images. //$fl->SetDPI(300); //$fl->SetMaximumImagePixels(5000000); // This line can be used to output Flate compressed background // images rather than DCTDecode compressed images which is the default //$fl->SetPreferJPG(false);