$doc->Close(); //-------------------------------------------------------------------------------- // Example 2) Reduce image quality and use jpeg compression for // non monochrome images. $doc = new PDFDoc($input_path . $input_filename . ".pdf"); $doc->InitSecurityHandler(); $image_settings = new ImageSettings(); // low quality jpeg compression $image_settings->SetCompressionMode(ImageSettings::e_jpeg); $image_settings->SetQuality(1); // Set the output dpi to be standard screen resolution $image_settings->SetImageDPI(144, 96); // this option will recompress images not compressed with // jpeg compression and use the result if the new image // is smaller. $image_settings->ForceRecompression(true); // this option is not commonly used since it can // potentially lead to larger files. It should be enabled // only if the output compression specified should be applied // to every image of a given type regardless of the output image size //$image_settings->ForceChanges(true); $opt_settings = new OptimizerSettings(); $opt_settings->SetColorImageSettings($image_settings); $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.