Loading...
Searching...
No Matches
Optimizer.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5#ifndef PDFTRON_H_CPPPDFOptimizer
6#define PDFTRON_H_CPPPDFOptimizer
7
8#include <PDF/PDFDoc.h>
9#include <C/PDF/TRN_Optimizer.h>
10
11 namespace pdftron{
12 namespace PDF{
13
14
15 class ImageSettings;
16 class MonoImageSettings;
17 class TextSettings;
18 class OptimizerSettings;
19
41 class Optimizer
42{
43 public:
44 typedef pdftron::PDF::ImageSettings ImageSettings;
45 typedef pdftron::PDF::MonoImageSettings MonoImageSettings;
46 typedef pdftron::PDF::TextSettings TextSettings;
47 typedef pdftron::PDF::OptimizerSettings OptimizerSettings;
48
49
60 static void Optimize(PDFDoc& doc, const OptimizerSettings& settings);
61 static void Optimize(PDFDoc& doc);
62
63 // @cond PRIVATE_DOC
64
65#ifndef SWIGHIDDEN
66 private:
67 Optimizer() {};
68#endif
69 // @endcond
70
71};
72
73
78 class ImageSettings : public TRN_OptimizerImageSettings
79{
80 public:
81 enum CompressionMode
82 {
83 e_retain,
84 e_flate,
85 e_jpeg,
86 e_jpeg2000,
87 e_none
88 };
89
90 enum DownsampleMode
91 {
92 e_off,
93 e_default
94 };
95
98 ImageSettings();
99
108 void SetImageDPI(double maximum,double resampling);
109
115 void SetCompressionMode(enum CompressionMode mode);
116
122 void SetDownsampleMode(enum DownsampleMode mode);
123
129 void SetQuality(UInt32 quality);
130
139 void ForceRecompression(bool force);
140
146 void ForceChanges(bool force);
147};
148
153 class MonoImageSettings : public TRN_OptimizerMonoImageSettings
154{
155 public:
156 enum CompressionMode
157 {
158 e_jbig2,
159 e_flate,
160 e_none,
161 e_ccitt
162 };
163
164 enum DownsampleMode
165 {
166 e_off,
167 e_default
168 };
169
173 MonoImageSettings();
174
183 void SetImageDPI(double maximum,double resampling);
184
190 void SetCompressionMode(enum CompressionMode mode);
191
192
198 void SetDownsampleMode(enum DownsampleMode mode);
199
200
209 void ForceRecompression(bool force);
210
216 void ForceChanges(bool force);
217
224 void SetJBIG2Threshold(double jbig2_threshold);
225
226};
227
231 class TextSettings : public TRN_OptimizerTextSettings
232{
233 public:
237 TextSettings();
238
245 void SubsetFonts(bool subset);
246
254 void EmbedFonts(bool embed);
255};
256
260 class OptimizerSettings
261{
262 public:
266 OptimizerSettings();
267
271 void SetColorImageSettings(const ImageSettings& settings);
272
276 void SetGrayscaleImageSettings(const ImageSettings& settings);
277
281 void SetMonoImageSettings(const MonoImageSettings& settings);
282
286 void SetTextSettings(const TextSettings& settings);
287
292 void RemoveCustomEntries(bool should_remove);
293
294 ImageSettings m_color_image_settings;
295 ImageSettings m_grayscale_image_settings;
296 MonoImageSettings m_mono_image_settings;
297 TextSettings m_text_settings;
298 bool m_remove_custom;
299};
300
301
302#include <Impl/Optimizer.inl>
303
304 } // namespace PDF
305} // namespace pdftron
306
307#endif // PDFTRON_H_CPPPDFOptimizer
PDFDoc.h
pdftron::PDF::ImageSettings
Definition Optimizer.h:79
pdftron::PDF::ImageSettings::SetImageDPI
void SetImageDPI(double maximum, double resampling)
pdftron::PDF::ImageSettings::DownsampleMode
DownsampleMode
Definition Optimizer.h:91
pdftron::PDF::ImageSettings::e_off
@ e_off
Definition Optimizer.h:92
pdftron::PDF::ImageSettings::e_default
@ e_default
Definition Optimizer.h:93
pdftron::PDF::ImageSettings::ForceRecompression
void ForceRecompression(bool force)
pdftron::PDF::ImageSettings::SetCompressionMode
void SetCompressionMode(enum CompressionMode mode)
pdftron::PDF::ImageSettings::SetQuality
void SetQuality(UInt32 quality)
pdftron::PDF::ImageSettings::ImageSettings
ImageSettings()
pdftron::PDF::ImageSettings::SetDownsampleMode
void SetDownsampleMode(enum DownsampleMode mode)
pdftron::PDF::ImageSettings::CompressionMode
CompressionMode
Definition Optimizer.h:82
pdftron::PDF::ImageSettings::e_jpeg
@ e_jpeg
Definition Optimizer.h:85
pdftron::PDF::ImageSettings::e_retain
@ e_retain
Definition Optimizer.h:83
pdftron::PDF::ImageSettings::e_flate
@ e_flate
Definition Optimizer.h:84
pdftron::PDF::ImageSettings::e_jpeg2000
@ e_jpeg2000
Definition Optimizer.h:86
pdftron::PDF::ImageSettings::e_none
@ e_none
Definition Optimizer.h:87
pdftron::PDF::ImageSettings::ForceChanges
void ForceChanges(bool force)
pdftron::PDF::MonoImageSettings
Definition Optimizer.h:154
pdftron::PDF::MonoImageSettings::DownsampleMode
DownsampleMode
Definition Optimizer.h:165
pdftron::PDF::MonoImageSettings::e_off
@ e_off
Definition Optimizer.h:166
pdftron::PDF::MonoImageSettings::e_default
@ e_default
Definition Optimizer.h:167
pdftron::PDF::MonoImageSettings::SetImageDPI
void SetImageDPI(double maximum, double resampling)
pdftron::PDF::MonoImageSettings::MonoImageSettings
MonoImageSettings()
pdftron::PDF::MonoImageSettings::ForceRecompression
void ForceRecompression(bool force)
pdftron::PDF::MonoImageSettings::CompressionMode
CompressionMode
Definition Optimizer.h:157
pdftron::PDF::MonoImageSettings::e_none
@ e_none
Definition Optimizer.h:160
pdftron::PDF::MonoImageSettings::e_jbig2
@ e_jbig2
Definition Optimizer.h:158
pdftron::PDF::MonoImageSettings::e_ccitt
@ e_ccitt
Definition Optimizer.h:161
pdftron::PDF::MonoImageSettings::e_flate
@ e_flate
Definition Optimizer.h:159
pdftron::PDF::MonoImageSettings::SetCompressionMode
void SetCompressionMode(enum CompressionMode mode)
pdftron::PDF::MonoImageSettings::ForceChanges
void ForceChanges(bool force)
pdftron::PDF::MonoImageSettings::SetJBIG2Threshold
void SetJBIG2Threshold(double jbig2_threshold)
pdftron::PDF::MonoImageSettings::SetDownsampleMode
void SetDownsampleMode(enum DownsampleMode mode)
pdftron::PDF::Optimizer
Definition Optimizer.h:42
pdftron::PDF::Optimizer::Optimize
static void Optimize(PDFDoc &doc)
pdftron::PDF::Optimizer::OptimizerSettings
pdftron::PDF::OptimizerSettings OptimizerSettings
Definition Optimizer.h:47
pdftron::PDF::Optimizer::MonoImageSettings
pdftron::PDF::MonoImageSettings MonoImageSettings
Definition Optimizer.h:45
pdftron::PDF::Optimizer::TextSettings
pdftron::PDF::TextSettings TextSettings
Definition Optimizer.h:46
pdftron::PDF::Optimizer::ImageSettings
pdftron::PDF::ImageSettings ImageSettings
Definition Optimizer.h:44
pdftron::PDF::Optimizer::Optimize
static void Optimize(PDFDoc &doc, const OptimizerSettings &settings)
pdftron::PDF::OptimizerSettings
Definition Optimizer.h:261
pdftron::PDF::OptimizerSettings::m_text_settings
TextSettings m_text_settings
Definition Optimizer.h:297
pdftron::PDF::OptimizerSettings::m_color_image_settings
ImageSettings m_color_image_settings
Definition Optimizer.h:294
pdftron::PDF::OptimizerSettings::OptimizerSettings
OptimizerSettings()
pdftron::PDF::OptimizerSettings::SetGrayscaleImageSettings
void SetGrayscaleImageSettings(const ImageSettings &settings)
pdftron::PDF::OptimizerSettings::SetColorImageSettings
void SetColorImageSettings(const ImageSettings &settings)
pdftron::PDF::OptimizerSettings::SetMonoImageSettings
void SetMonoImageSettings(const MonoImageSettings &settings)
pdftron::PDF::OptimizerSettings::m_grayscale_image_settings
ImageSettings m_grayscale_image_settings
Definition Optimizer.h:295
pdftron::PDF::OptimizerSettings::m_mono_image_settings
MonoImageSettings m_mono_image_settings
Definition Optimizer.h:296
pdftron::PDF::OptimizerSettings::SetTextSettings
void SetTextSettings(const TextSettings &settings)
pdftron::PDF::OptimizerSettings::m_remove_custom
bool m_remove_custom
Definition Optimizer.h:298
pdftron::PDF::OptimizerSettings::RemoveCustomEntries
void RemoveCustomEntries(bool should_remove)
pdftron::PDF::PDFDoc
Definition PDFDoc.h:72
pdftron::PDF::TextSettings
Definition Optimizer.h:232
pdftron::PDF::TextSettings::EmbedFonts
void EmbedFonts(bool embed)
pdftron::PDF::TextSettings::TextSettings
TextSettings()
pdftron::PDF::TextSettings::SubsetFonts
void SubsetFonts(bool subset)
pdftron::PDF
Definition Action.h:15
pdftron
Definition BasicTypes.h:10
pdftron::UInt32
TRN_UInt32 UInt32
Definition BasicTypes.h:13