←Select platform

MonoImageCompression Property

Summary
Compression format to use when saving a monochrome image.
Syntax
C#
C++/CLI
Java
Python
public RasterImageFormat MonoImageCompression { get; set; } 
public RasterImageFormat getMonoImageCompression(); 
public void setMonoImageCompression( 
   RasterImageFormat rasterImageFormat 
); 
public: 
property RasterImageFormat MonoImageCompression { 
   RasterImageFormat get(); 
   void set (    RasterImageFormat ); 
} 
MonoImageCompression # get and set (PDFOptimizerOptions) 

Property Value

The Leadtools.RasterImageFormat to use. Possible values: SupportedMonoImageFormats.

Example
C#
Java
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
 
 
public void PDFFileOptimizerOptionsExample() 
{ 
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf"); 
   string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_OptimizerOptions.pdf"); 
 
   PDFFile pdfFile = new PDFFile(sourceFileName); 
 
   PDFOptimizerOptions myOptimizerOptions = new PDFOptimizerOptions(); 
   myOptimizerOptions.AutoOptimizerMode = PDFAutoOptimizerMode.Customized; 
 
   myOptimizerOptions.ColorImageDownsamplingMode = PDFDownsamplingMode.Average; 
   myOptimizerOptions.GrayImageDownsamplingMode = PDFDownsamplingMode.Bicubic; 
   myOptimizerOptions.MonoImageDownsamplingMode = PDFDownsamplingMode.Bicubic; 
 
   myOptimizerOptions.ColorImageDownsampleFactor = 2.0; 
   myOptimizerOptions.GrayImageDownsampleFactor = 2.0; 
   myOptimizerOptions.MonoImageDownsampleFactor = 2.0; 
 
   myOptimizerOptions.ColorImageDPI = 150; 
   myOptimizerOptions.GrayImageDPI = 150; 
   myOptimizerOptions.MonoImageDPI = 150; 
 
   // To determine the accepted compression value for ColorImageCompression, GrayImageCompression and MonoImageCompression 
   // uncomment the necessary code below: 
   // 
   // ColorImageCompression 
   // RasterImageFormat[] grayImageFormatAcceptedCompression = PDFOptimizerOptions.SupportedGrayImageFormats; 
   // 
   // GrayImageCompression 
   // RasterImageFormat[] colorImageFormatAcceptedCompression = PDFOptimizerOptions.SupportedColorImageFormats; 
   // 
   // MonoImageCompression 
   // RasterImageFormat[] monoImageFormatAcceptedCompression = PDFOptimizerOptions.SupportedMonoImageFormats; 
 
   myOptimizerOptions.ColorImageCompression = RasterImageFormat.Jpeg; 
   myOptimizerOptions.GrayImageCompression = RasterImageFormat.Jpeg; 
   myOptimizerOptions.MonoImageCompression = RasterImageFormat.Jbig2; 
 
   myOptimizerOptions.EmbedAllFonts = false; 
   myOptimizerOptions.SubsetFonts = true; 
 
   pdfFile.OptimizerOptions = myOptimizerOptions; 
 
   pdfFile.Optimize(destinationFileName); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.ByteArrayInputStream; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.FileOutputStream; 
import java.io.FileReader; 
import java.io.IOException; 
import java.io.InputStream; 
import java.nio.file.Files; 
import java.nio.file.Paths; 
import java.nio.file.StandardCopyOption; 
import java.util.ArrayList; 
import java.util.Date; 
import java.util.List; 
import java.util.Scanner; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.pdf.*; 
 
 
public void pdfFileOptimizerOptionsExample() { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String sourceFileName = combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"); 
   String destinationFileName = combine(LEAD_VARS_IMAGES_DIR, 
         "LEAD_OptimizerOptions.pdf"); 
 
   PDFFile pdfFile = new PDFFile(sourceFileName); 
 
   PDFOptimizerOptions myOptimizerOptions = new PDFOptimizerOptions(); 
   myOptimizerOptions.setAutoOptimizerMode(PDFAutoOptimizerMode.CUSTOMIZED); 
 
   myOptimizerOptions.setColorImageDownsamplingMode(PDFDownsamplingMode.AVERAGE); 
   myOptimizerOptions.setGrayImageDownsamplingMode(PDFDownsamplingMode.BICUBIC); 
   myOptimizerOptions.setMonoImageDownsamplingMode(PDFDownsamplingMode.BICUBIC); 
 
   myOptimizerOptions.setColorImageDownsampleFactor(2.0); 
   myOptimizerOptions.setGrayImageDownsampleFactor(2.0); 
   myOptimizerOptions.setMonoImageDownsampleFactor(2.0); 
 
   myOptimizerOptions.setColorImageDPI(150); 
   myOptimizerOptions.setGrayImageDPI(150); 
   myOptimizerOptions.setMonoImageDPI(150); 
 
   // To determine the accepted compression value for ColorImageCompression, 
   // GrayImageCompression and MonoImageCompression: 
   // uncomment the necessary code below: 
   // 
   // ColorImageCompression 
   // RasterImageFormat[] grayImageFormatAcceptedCompression = 
   // PDFOptimizerOptions.SupportedGrayImageFormats; 
   // 
   // GrayImageCompression 
   // RasterImageFormat[] colorImageFormatAcceptedCompression = 
   // PDFOptimizerOptions.SupportedColorImageFormats; 
   // 
   // MonoImageCompression 
   // RasterImageFormat[] monoImageFormatAcceptedCompression = 
   // PDFOptimizerOptions.SupportedMonoImageFormats; 
 
   myOptimizerOptions.setColorImageCompression(RasterImageFormat.JPEG); 
   myOptimizerOptions.setGrayImageCompression(RasterImageFormat.JPEG); 
   myOptimizerOptions.setMonoImageCompression(RasterImageFormat.JBIG2); 
 
   myOptimizerOptions.setEmbedAllFonts(false); 
   myOptimizerOptions.setSubsetFonts(true); 
 
   pdfFile.setOptimizerOptions(myOptimizerOptions); 
 
   pdfFile.optimize(destinationFileName); 
   assertTrue(pdfFile.getOptimizerOptions().equals(myOptimizerOptions)); 
 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.