[SerializableAttribute()]
public class PDFOptimizerOptions
public class PDFOptimizerOptions
[SerializableAttribute()]
public ref class PDFOptimizerOptions
class PDFOptimizerOptions:
Use the PDFOptimizerOptions class to specify options that control the PDFFile optimizer when calling Optimize.
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));
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document