←Select platform

QualityFactor Property

Summary
Quality Factor (Q. Factor) for lossy image compression.
Syntax
C#
C++/CLI
Java
Python
public int QualityFactor { get; set; } 
public int getQualityFactor(); 
public void setQualityFactor( 
   int intValue 
); 
public: 
property int QualityFactor { 
   int get(); 
   void set (    int ); 
} 
QualityFactor # get and set (PDFOptimizerOptions) 

Property Value

The Quality Factor to use when saving compressed images.

Remarks

For more information see Leadtools.Codecs.CodecsJpegSaveOptions.QualityFactor.

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.