com.pdftools.pola
Class PdfOptimize

java.lang.Object
  extended by com.pdftools.NativeLibrary
      extended by com.pdftools.pola.PdfOptimize

public class PdfOptimize
extends NativeLibrary

The purpose of the PDF Image Optimization API is to adjust embedded raster images in a PDF to the specific needs, such as reducing the resolution for fast viewing via the web, or converting colors for printing.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.pdftools.NativeLibrary
NativeLibrary.COLORCONVERSION, NativeLibrary.COLORSPACE, NativeLibrary.COMPLIANCE, NativeLibrary.COMPRESSION, NativeLibrary.COMPRESSIONATTEMPT, NativeLibrary.CONVERSIONERROR, NativeLibrary.DITHERING, NativeLibrary.DITHERINGMODE, NativeLibrary.ERRORCODE, NativeLibrary.FONTTYPE, NativeLibrary.OPTIMIZATIONPROFILE, NativeLibrary.ORIENTATION, NativeLibrary.PDFCONFORMANCECATEGORY, NativeLibrary.PDFCOPYOPTION, NativeLibrary.PDFDESTMODE, NativeLibrary.PDFPAGELAYOUT, NativeLibrary.PDFPAGEMODE, NativeLibrary.PERMISSION, NativeLibrary.RENDEREROPTION, NativeLibrary.RENDEREROPTION2, NativeLibrary.RENDERINGMODE, NativeLibrary.RENDERINGPROPERTY, NativeLibrary.ROTATEMODE, NativeLibrary.STRIPTYPE, NativeLibrary.TEXTEXTCONFIGURATION
 
Field Summary
 
Fields inherited from class com.pdftools.NativeLibrary
VERSION
 
Constructor Summary
PdfOptimize()
          Simple Constructor
PdfOptimize(byte[] pData, java.lang.String strPassword)
          Deprecated. Deprecated in Version 4.7. Use PdfOptimize() and openMem(byte[], String) instead.
PdfOptimize(java.lang.String strPath, java.lang.String strPassword)
          Deprecated. Deprecated in Version 4.7. Use PdfOptimize() and open(String, String) instead.
 
Method Summary
 boolean close()
          Closes the currently open input file(s).
 void destroyObject()
          Release handle for the process.
 int getBitonalCompression()
          Deprecated. Deprecated in Version 4.6. Use getBitonalCompressions() instead.
 int getBitonalCompressions()
          Get the compression types for bi-tonal (black and white) images.
 float getBitonalResolutionDPI()
          Get the target resolution in dots per inch (DPI) after re-sampling images for bi-tonal images.
 float getBitonalThresholdDPI()
          Get the threshold resolution in dots per inch (DPI) for bi-tonal images.
 boolean getClipImages()
          Get whether invisible parts of images are clipped (cropped).
 int getColorCompression()
          Deprecated. Deprecated in Version 4.6. Use getContinuousCompressions() instead.
 int getColorConversion()
          Get the color conversion to use on color images, see NativeLibrary.COLORCONVERSION.
 float getColorResolutionDPI()
          Get the target resolution in dots per inch (DPI) after re-sampling images for color images.
 float getColorThresholdDPI()
          Get the threshold resolution in dots per inch (DPI) for color images.
 int getCompressionQuality()
          Deprecated. Use getImageQuality() instead.
 int getContinuousCompressions()
          Get the compression types to be tried for continuous images, i.e.
 boolean getConvertToCFF()
          Get whether embedded Type1 (PostScript) fonts shall be converted to Type1C (Compact Font Format).
 int getDitheringMode()
          Get whether dithering is enabled or disabled when down-sampling bi-tonal images.
 int getErrorCode()
          Get the latest error code.
 boolean getExtractFonts()
          Get the switch to extract the embedded fonts.
 boolean getExtractImages()
          Get whether images are extracted.
 boolean getFlattenSignatureFields()
          Get whether appearances of signature fields are flattened.
 boolean getForceCompressionTypes()
          Get whether image re-compression is forced if an image in the input PDF has a compression type that differs from the compression types given in setContinuousCompressions(int), setBitonalCompressions(int), or setIndexedCompressions(int).
 boolean getForceRecompression()
          Get whether images are always re-compressed using the specified image compression and other image parameters.
 int getImageQuality()
          Get the quality index of the lossy compression.
 boolean getImageStratConserv()
          Deprecated. Deprecated in Version 4.7. Get the switch for the conservative image processing strategy: Only try re-compressing an image if it has either been clipped ( setClipImages(boolean)), re-sampled ( setResolutionDPI(float), setThresholdDPI(float)), or if it has undergone a color conversion (setColorConversion(int)), or if setForceRecompression(boolean) is enabled. Otherwise the original input image is taken as is.
 int getIndexedCompressions()
          Get the compression types for images that have an indexed ("palette") color space.
static boolean getLicenseIsValid()
          Check if a valid license is loaded.
 boolean getLinearize()
          Get whether the PDF output file will be linearized, i.e.
 boolean getMergeEmbeddedFonts()
          Get the switch to merge embedded font programs.
 int getMonochromeCompression()
          Deprecated. Deprecated in Version 4.6. Use getContinuousCompressions() instead.
 float getMonochromeResolutionDPI()
          Get the target resolution in dots per inch (DPI) after re-sampling images for monochrome images.
 float getMonochromeThresholdDPI()
          Get the threshold resolution in dots per inch (DPI) for monochrome images.
 int getMrcLayerCompression()
          Get the compression type for MRC foreground and background layers.
 int getMrcLayerQuality()
          Get the image quality for MRC foreground and background layers when using a lossy compression type.
 float getMrcLayerResolutionDPI()
          Get the target resolution in DPI for down-sampling MRC foreground and background layers.
 int getMrcMaskCompression()
          Get the compression type for MRC masks.
 int getMrcPictCompression()
          Get the compression type for MRC cut-out pictures.
 boolean getMrcRecognizePictures()
          Get the option to recognize areas of photographic pictures when doing MRC.
 boolean getOptimizeResources()
          Get whether resources shall be optimized.
 int getPageCount()
          Get the number of total pages of the input document.
 byte[] getPdf()
          Get the PDF output file previously stored in memory.
static java.lang.String getProductVersion()
          Get the version of the product
 boolean getReduceColorComplexity()
          Get whether the color complexity of images is reduced.
 boolean getRemoveImages()
          Get whether images are removed.
 boolean getRemoveNonSymbolicFonts()
          Deprecated. Deprecated in Version 4.7.
 boolean getRemoveReduntantObjects()
          Get whether redundant objects shall be removed.
 boolean getRemoveStandardFonts()
          Get whether the font programs of all embedded standard fonts shall be removed, such as Arial, Courier, CourierNew, Helvetica, Symbol, Times, TimesNewRoman and ZapfDingbats.
 float getResolutionDPI()
          Get the target resolution in dots per inch (DPI) after re-sampling images.
 int getStrip()
          Get the stripping mode: This mode can be configured to remove unneeded data of a PDF document such as Threads, Metadata, the PieceInfo, the StructTreeRoot entry, embedded Thumbs and the SpiderInfo entry.
 boolean getSubsetFonts()
          Get whether embedded fonts are subset and embedded font programs of different subsets of the same font merged.
 float getThresholdDPI()
          Get the threshold resolution in DPI above which images are re-sampled.
static boolean linearizeFile(java.lang.String strInFileName, java.lang.String strPassword, java.lang.String strOutFileName, java.lang.String strUserPw, java.lang.String strOwnerPw, int iPermissionFlags)
          Linearize a PDF file and save the result as a new PDF file, which is optimized for fast web view.
 boolean listFonts(java.lang.String strFileName)
          List all fonts included in the document and write them as a list to a text file.
 boolean listImages(java.lang.String strFileName)
          List all images included in the document and write them as a list to a text file.
 boolean open(java.lang.String strPath, java.lang.String strPassword)
          Open a PDF file, i.e.
 boolean openMem(byte[] pData, java.lang.String strPassword)
          Open an input PDF memory block, i.e.
 boolean renameFont(java.lang.String strFontName1, java.lang.String strFontName2)
          Deprecated.  
 boolean saveAs(java.lang.String strpath, java.lang.String strUserPw, java.lang.String strOwnerPw, int iPermissionFlags)
          Create an output PDF document and store the optimized input file.
 boolean saveInMemory()
          Save the output PDF in memory.
 void setBitonalCompression(int iCompression)
          Deprecated. Deprecated in Version 4.6. Use setBitonalCompressions(int) instead.
 void setBitonalCompressions(int iCompression)
          Set the compression types for bi-tonal (black and white) images.
 void setBitonalResolutionDPI(float fResolutionDPI)
          Set the target resolution in dots per inch (DPI) after re-sampling images for bi-tonal images.
 void setBitonalThresholdDPI(float fThresholdDPI)
          Set the threshold resolution in dots per inch (DPI) to selectively activate re-sampling for bi-tonal images.
 void setClipImages(boolean bClip)
          Clip invisible parts of images.
static boolean setCMSEngine(java.lang.String sCMSEngine)
          Set the name of the Color Management System (CMS) engine (None, Neugebauer, lcms or a filename).
 void setColorCompression(int iCompression)
          Deprecated. Deprecated in Version 4.6. Use setContinuousCompressions(int) instead.
 void setColorConversion(int iColorConversion)
          Set the color conversion to use on color images.
 void setColorResolutionDPI(float fResolutionDPI)
          Set the target resolution in dots per inch (DPI) after re-sampling images for color images.
 void setColorThresholdDPI(float fThresholdDPI)
          Set the threshold resolution in dots per inch (DPI) to selectively activate re-sampling for color images.
 void setCompressionQuality(int iQuality)
          Deprecated. Use setImageQuality(int) instead.
 void setContinuousCompressions(int iCompression)
          Set the compression types to be tried for continuous images, i.e.
 void setConvertToCFF(boolean bConvertToCFF)
          Set the switch to convert embedded Type1 (PostScript) fonts to Type1C (Compact Font Format).
 void setDitheringMode(int iDithering)
          Enable or disable dithering when down-sampling bi-tonal images.
 void setExtractFonts(boolean bExtract)
          Set the switch to extract the embedded fonts.
 void setExtractImages(boolean bExtract)
          Images can be extracted to individual image files during processing of the PDF file.
 void setFlattenSignatureFields(boolean bFlatten)
          A signature in a PDF consist of two parts: The invisible digital signature in the PDF The visual appearance that was attributed to the signature Part 1 can be used by a viewing application, to verify that a document has not changed since it has been signed and report this to the user.
 void setForceCompressionTypes(boolean bForce)
          Set the switch to force re-compression of images if an image in the input PDF has a compression type that differs from the compression types given in setContinuousCompressions(int), setBitonalCompressions(int), or setIndexedCompressions(int).
 void setForceRecompression(boolean bForce)
          Set the switch to always re-compress images using the specified image compression and other image parameters.
 void setImageQuality(int iQuality)
          Set the quality index of the lossy compression.
 void setImageStratConserv(boolean bForce)
          Deprecated. Deprecated in Version 4.7. Set the switch for the conservative image processing strategy: Only try re-compressing an image if it has either been clipped ( setClipImages(boolean)), re-sampled ( setResolutionDPI(float), setThresholdDPI(float)), or if it has undergone a color conversion ( setColorConversion(int)), or if setForceRecompression(boolean) is enabled. Otherwise the original input image is taken as is.
 void setIndexedCompressions(int iCompression)
          Set the compression types for images that have an indexed ("palette") color space.
 boolean setInfoEntry(java.lang.String sKey, java.lang.String sValue)
          Set the value of an info entry key.
static boolean setLicenseKey(java.lang.String licenseKey)
          Set the license key.
 void setLinearize(boolean bLinearize)
          Set whether to linearize the PDF output file, i.e.
 void setMergeEmbeddedFonts(boolean bSubset)
          Set the switch to merge embedded font programs.
 void setMonochromeCompression(int iCompression)
          Deprecated. Deprecated in Version 4.6. Use setContinuousCompressions(int) instead.
 void setMonochromeResolutionDPI(float fResolutionDPI)
          Set the target resolution in dots per inch (DPI) after re-sampling images for monochrome images.
 void setMonochromeThresholdDPI(float fThresholdDPI)
          Set the threshold resolution in dots per inch (DPI) to selectively activate re-sampling for monochrome images.
 void setMrcLayerCompression(int iCompression)
          Set the compression type for MRC foreground and background layers.
 void setMrcLayerQuality(int iQuality)
          Set the image quality for MRC foreground and background layers when using a lossy compression type.
 void setMrcLayerResolutionDPI(float fResolutionDPI)
          Set the target resolution in DPI for down-sampling MRC foreground and background layers.
 void setMrcMaskCompression(int iCompression)
          Set the compression type for MRC masks.
 void setMrcPictCompression(int iCompression)
          Set the compression type for MRC cut-out pictures.
 void setMrcRecognizePictures(boolean bRecognize)
          Set the option to recognize areas of photographic pictures when doing MRC.
 void setOptimizeResources(boolean bOptimize)
          Set whether resources should be optimized.
 void setProfile(int iProfile)
          Set the optimization profile.
 void setReduceColorComplexity(boolean bClip)
          Convert images to their least complex color space.
 void setRemoveImages(boolean bClip)
          Remove images.
 void setRemoveNonSymbolicFonts(boolean bRemove)
          Deprecated. Deprecated in Version 4.7.
 void setRemoveRedundantObjects(boolean bRemove)
          Set whether redundant objects should be removed.
 void setRemoveStandardFonts(boolean bRemove)
          Set whether to remove the font programs of all embedded standard fonts, such as Arial, Courier, CourierNew, Helvetica, Symbol, Times, TimesNewRoman and ZapfDingbats.
 void setResolutionDPI(float fResolutionDPI)
          Set the target resolution in dots per inch (DPI) after re-sampling images.
 void setStrip(int iStripModes)
          Set the stripping mode: This mode can be configured to remove unneeded data of a PDF document such as Threads, Metadata, the PieceInfo, the StructTreeRoot entry, embedded Thumbs and the SpiderInfo entry.
 void setSubsetFonts(boolean bSubset)
          Subset embedded fonts and merge embedded font programs of different subsets of the same font, granted they can be merged.
 void setThresholdDPI(float fThresholdDPI)
          Set the threshold in DPI to selectively activate re-sampling.
 boolean setVersion(java.lang.String strVersion)
          Set the minimum PDF version of the created PDF output file.
 boolean unembedFont(java.lang.String strFontName)
          Remove an embedded font program.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfOptimize

public PdfOptimize()
Simple Constructor


PdfOptimize

public PdfOptimize(java.lang.String strPath,
                   java.lang.String strPassword)
Deprecated. Deprecated in Version 4.7. Use PdfOptimize() and open(String, String) instead.

Parameters:
strPath - the file path of the existing PDF residing in the file system
strPassword - the password to be used to decrypt a password protected input PDF

PdfOptimize

public PdfOptimize(byte[] pData,
                   java.lang.String strPassword)
Deprecated. Deprecated in Version 4.7. Use PdfOptimize() and openMem(byte[], String) instead.

Parameters:
pData - the memory block containing the PDF file given as a one dimensional byte array
strPassword - the password to be used to decrypt a password protected input PDF
Method Detail

setLicenseKey

public static boolean setLicenseKey(java.lang.String licenseKey)
Set the license key.

Parameters:
licenseKey - The license key
Returns:
true if the license is valid.

getLicenseIsValid

public static boolean getLicenseIsValid()
Check if a valid license is loaded.

Returns:
true if a valid license is loaded.

getProductVersion

public static java.lang.String getProductVersion()
Get the version of the product

Returns:
a string in the format 'A.B.C.D'.

setCMSEngine

public static boolean setCMSEngine(java.lang.String sCMSEngine)
Set the name of the Color Management System (CMS) engine (None, Neugebauer, lcms or a filename). Choose among the available color management engines to transform colors.

"None": If this switch is set to none then the algorithms specified in the PDF reference are used. This results in the maximum possible contrast.

"Neugebauer": The Neugebauer algorithm efficiently converts CMYK to RGB. It does not need any color profiles. The results, however, look similar to conversion using color profiles.

"lcms" (default): Use ICC color profiles. Default profiles are used for all unmanaged device color spaces.

FileName: Providing a file name, a configurable version of the Neugebauer algorithm is applied. The coefficients can be defined in the text file. The Neugebauer algorithm mixes the colors based on the amount of color and the corresponding weighted coefficient. Altering the values for a pure color specifically changes the result for this pure color. The color transition remains smooth.

Parameters:
sCMSEngine - Name of the CMS Engine
Returns:
true on success

destroyObject

public void destroyObject()
Release handle for the process.


open

public boolean open(java.lang.String strPath,
                    java.lang.String strPassword)
Open a PDF file, i.e. make the objects contained in the document accessible. If a document is already open, it is closed first.

Parameters:
strPath - the file path of the existing PDF residing in the file system
strPassword - the user or owner password to be used to decrypt a password protected input PDF. If this parameter is left out an empty string is used as a default.
Returns:
true: The file could be successfully opened. false: The file does not exist, it is corrupt, or the password is not valid. Use getErrorCode() for additional information.

openMem

public boolean openMem(byte[] pData,
                       java.lang.String strPassword)
Open an input PDF memory block, i.e. make the objects contained in the document accessible. If a document is already open, it is closed first.

Parameters:
pData - the memory block containing the PDF file given as a one dimensional byte array
strPassword - the user or owner password to be used to decrypt a password protected input PDF. If this parameter is left out an empty string is used as a default.
Returns:
true: The file could be successfully opened. false: The file does not exist, it is corrupt, or the password is not valid.

saveAs

public boolean saveAs(java.lang.String strpath,
                      java.lang.String strUserPw,
                      java.lang.String strOwnerPw,
                      int iPermissionFlags)
Create an output PDF document and store the optimized input file. To not encrypt the output document, use ePermNoEncryption or –1 and no user and owner password. In order to allow high quality printing, the flags ePermPrint and ePermDigitalPrint need to be set.

Parameters:
strpath - the name of the PDF output file to be created
strUserPw - the user password for encrypting the PDF document. If this parameter is omitted, the default password is used. Use "" to set no password.
strOwnerPw - the owner password for encrypting the PDF document. If this parameter is omitted, the default password is used. Use "" to set no password.
iPermissionFlags - Permissions to set for encrypted PDF files encoded as integer number (see class NativeLibrary.PERMISSION). By default no encryption is used (-1).
Returns:
true: The opened document could successfully be saved to file. false: The output file cannot be created, it is recommended to abort the processing of the file and log the error code and error message.

saveInMemory

public boolean saveInMemory()
Save the output PDF in memory. After the close() call it can be accessed using the method getPdf().

Returns:
true: The PDF data could be saved in memory. false otherwise.

getPdf

public byte[] getPdf()
Get the PDF output file previously stored in memory. See also saveInMemory().

Returns:
A byte array containing the PDF document.

close

public boolean close()
Closes the currently open input file(s). If the document is already closed the method does nothing.

Returns:
true: The file could be closed successfully. false otherwise.

getErrorCode

public int getErrorCode()
Get the latest error code.

Returns:
The code describing the last error that occurred while processing.
See Also:
NativeLibrary.ERRORCODE

getBitonalCompression

public int getBitonalCompression()
Deprecated. Deprecated in Version 4.6. Use getBitonalCompressions() instead.

Returns:
the first compression type for bitonal images, see NativeLibrary.COMPRESSION

setBitonalCompression

public void setBitonalCompression(int iCompression)
Deprecated. Deprecated in Version 4.6. Use setBitonalCompressions(int) instead.

Set a single compression type to be used for bitonal (black and white) images

Parameters:
iCompression - the compression type; for valid compression types, see NativeLibrary.COMPRESSION

getBitonalCompressions

public int getBitonalCompressions()
Get the compression types for bi-tonal (black and white) images. Typically, CCITT G4 or JBIG2 is used for bi-tonal compression. Due to the simpler algorithm CCITT G4 has the advantage of being faster. JBIG2 can achieve compression ratios that are up to twice as high as CCITT G4 at the cost of longer computation time.

Returns:
the compression types currently active for bi-tonal images, see NativeLibrary.COMPRESSIONATTEMPT.

setBitonalCompressions

public void setBitonalCompressions(int iCompression)
Set the compression types for bi-tonal (black and white) images. Typically, CCITT G4 or JBIG2 is used for bi-tonal compression. Due to the simpler algorithm CCITT G4 has the advantage of being faster. JBIG2 can achieve compression ratios that are up to twice as high as CCITT G4 at the cost of longer computation time.
Several values can be combined with bitwise or operators. The following values are allowed: Other values are ignored.

Parameters:
iCompression - the compression types; for valid compression types, see NativeLibrary.COMPRESSIONATTEMPT.

getMonochromeCompression

public int getMonochromeCompression()
Deprecated. Deprecated in Version 4.6. Use getContinuousCompressions() instead.

Returns:
the first compression type for continuous (monochrome and color) images, see NativeLibrary.COMPRESSION

setMonochromeCompression

public void setMonochromeCompression(int iCompression)
Deprecated. Deprecated in Version 4.6. Use setContinuousCompressions(int) instead.

Set a single compression type to be used for continuous (monochrome and color) images.

Parameters:
iCompression - the compression type; for valid compression types, see NativeLibrary.COMPRESSION

getColorCompression

public int getColorCompression()
Deprecated. Deprecated in Version 4.6. Use getContinuousCompressions() instead.

Returns:
the first compression type for continuous (monochrome and color) images, see NativeLibrary.COMPRESSION

setColorCompression

public void setColorCompression(int iCompression)
Deprecated. Deprecated in Version 4.6. Use setContinuousCompressions(int) instead.

Set a single compression type to be used for continuous (monochrome and color) images

Parameters:
iCompression - the compression type; for valid values, see NativeLibrary.COMPRESSION

getContinuousCompressions

public int getContinuousCompressions()
Get the compression types to be tried for continuous images, i.e. RGB, CMYK, and grayscale images.

Returns:
the compression types currently active for continuous (monochrome and color) images, see NativeLibrary.COMPRESSIONATTEMPT.

setContinuousCompressions

public void setContinuousCompressions(int iCompression)
Set the compression types to be tried for continuous images, i.e. RGB, CMYK, and grayscale images. Several values can be combined with bitwise or operators. The following values are allowed: Other values are ignored.

Parameters:
iCompression - the compression types; for valid values, see NativeLibrary.COMPRESSIONATTEMPT.

getIndexedCompressions

public int getIndexedCompressions()
Get the compression types for images that have an indexed ("palette") color space.

Returns:
the compression types currently active for indexed images, see NativeLibrary.COMPRESSION.

setIndexedCompressions

public void setIndexedCompressions(int iCompression)
Set the compression types for images that have an indexed ("palette") color space. Several values can be combined with bitwise or operators. The following values are allowed: Other values are ignored.

Parameters:
iCompression - the compression types; for valid values, see NativeLibrary.COMPRESSIONATTEMPT.

getForceRecompression

public boolean getForceRecompression()
Get whether images are always re-compressed using the specified image compression and other image parameters. If not set, images are only re-compressed if the resulting image is smaller than the original, i.e. requires less bytes to store in the file.

Returns:
true if images shall always be re-compressed.

setForceRecompression

public void setForceRecompression(boolean bForce)
Set the switch to always re-compress images using the specified image compression and other image parameters. If not set, images are only re-compressed if the resulting image is smaller than the original, i.e. requires less bytes to store in the file.

Parameters:
bForce - true to always re-compress images.

getForceCompressionTypes

public boolean getForceCompressionTypes()
Get whether image re-compression is forced if an image in the input PDF has a compression type that differs from the compression types given in setContinuousCompressions(int), setBitonalCompressions(int), or setIndexedCompressions(int).

Returns:
true if images shall always have one of the set compression types.

setForceCompressionTypes

public void setForceCompressionTypes(boolean bForce)
Set the switch to force re-compression of images if an image in the input PDF has a compression type that differs from the compression types given in setContinuousCompressions(int), setBitonalCompressions(int), or setIndexedCompressions(int). Use this option if you want to allow only the given compression types for images in the output PDF.

Parameters:
bForce - true if images shall always have one of the set compression types.

getImageStratConserv

public boolean getImageStratConserv()
Deprecated. Deprecated in Version 4.7. Get the switch for the conservative image processing strategy: Only try re-compressing an image if it has either been clipped ( setClipImages(boolean)), re-sampled ( setResolutionDPI(float), setThresholdDPI(float)), or if it has undergone a color conversion (setColorConversion(int)), or if setForceRecompression(boolean) is enabled. Otherwise the original input image is taken as is.

Returns:
true if conservative image processing strategy is enabled.

setImageStratConserv

public void setImageStratConserv(boolean bForce)
Deprecated. Deprecated in Version 4.7. Set the switch for the conservative image processing strategy: Only try re-compressing an image if it has either been clipped ( setClipImages(boolean)), re-sampled ( setResolutionDPI(float), setThresholdDPI(float)), or if it has undergone a color conversion ( setColorConversion(int)), or if setForceRecompression(boolean) is enabled. Otherwise the original input image is taken as is.

Parameters:
bForce - true to enable conservative image processing strategy.

getResolutionDPI

public float getResolutionDPI()
Get the target resolution in dots per inch (DPI) after re-sampling images. getResolutionDPI returns the target resolution in DPI for color images. The typical value for the resolution when optimizing for the web is 150 DPI. For printing typically no re-sampling is applied (see setThresholdDPI(float)).

Returns:
the target resolution in DPI for color images.

setResolutionDPI

public void setResolutionDPI(float fResolutionDPI)
Set the target resolution in dots per inch (DPI) after re-sampling images. This property affects all three image compression types (bi-tonal, monochrome, color). The typical value for the resolution when optimizing for the web is 150 DPI. For printing typically no re-sampling is applied (see setThresholdDPI(float)). Pre-blended images, images with a color key mask, mask, and soft mask images are not re-sampled.

Parameters:
fResolutionDPI - the resolution in DPI to which the images shall be down-sampled.

setThresholdDPI

public void setThresholdDPI(float fThresholdDPI)
Set the threshold in DPI to selectively activate re-sampling. Only images with a resolution above the threshold DPI will be re-sampled. The typical threshold value when optimizing for the web is 225 DPI (default). setThresholdDPI affects all three image compression types (bi-tonal, monochrome, color). Set to -1 to deactivate re-sampling.

Parameters:
fThresholdDPI - the new threshold value.

getThresholdDPI

public float getThresholdDPI()
Get the threshold resolution in DPI above which images are re-sampled.

Returns:
the active threshold value

getColorConversion

public int getColorConversion()
Get the color conversion to use on color images, see NativeLibrary.COLORCONVERSION.

Returns:
the conversion mode set for color images.

setColorConversion

public void setColorConversion(int iColorConversion)
Set the color conversion to use on color images.

The image can be not converted (eConvNone), converted to RGB (eConvRGB), to CMYK or gray scale. Color key masked images are not color converted. Pre-blended images can be converted from RGB to grayscale, if the force conversion feature is set.

Color conversion is applied before re-sampling. Therefore converting to grayscale will make the grayscale DPI and threshold DPI the reference values for the originally colored images.

Color conversion is mostly used for specific application areas. E.g. in the printing industry the CMYK color space is used, since it represents the colors that printer devices commonly support. If colors are exclusively used for the monitor, the RGB color space should be used.

Parameters:
iColorConversion - the conversion mode; for valid values, see NativeLibrary.COLORCONVERSION.

getDitheringMode

public int getDitheringMode()
Get whether dithering is enabled or disabled when down-sampling bi-tonal images.

Returns:
the dithering mode for down-sampling bitonal images, see NativeLibrary.DITHERINGMODE.

setDitheringMode

public void setDitheringMode(int iDithering)
Enable or disable dithering when down-sampling bi-tonal images.

Note: The only values supported are eDitherNone and eDitherFloydSteinberg.

Some bi-tonal images try to evoke the impression of different levels of gray by randomly setting pixels to black. If dithering is applied during down-sampling then the gray levels of such images are preserved better. If dithering is switched off then lines (e.g. text glyphs) are preserved better.

Parameters:
iDithering - the dithering mode; for valid values, see NativeLibrary.DITHERINGMODE. Currently, only eDitherNone and eDitherFloydSteinberg are available.

getImageQuality

public int getImageQuality()
Get the quality index of the lossy compression. This is a value from 1 to 100. This can be applied for JPEG and JPEG2000 compression. For JPEG2000, a quality index of 100 means lossless compression. JPEG compression is always lossy.

Returns:
the currently active image compression quality value (0..100)

setImageQuality

public void setImageQuality(int iQuality)
Set the quality index of the lossy compression. This is a value from 1 to 100. This can be applied for JPEG and JPEG2000 compression. For JPEG2000, a quality index of 100 means lossless compression. JPEG compression is always lossy.

Parameters:
iQuality - the new quality value (0..100)

getCompressionQuality

public int getCompressionQuality()
Deprecated. Use getImageQuality() instead.

Returns:
the currently active compression quality value

setCompressionQuality

public void setCompressionQuality(int iQuality)
Deprecated. Use setImageQuality(int) instead.

Set the compression quality for compressing to JPEG.

Parameters:
iQuality - the new quality value

getClipImages

public boolean getClipImages()
Get whether invisible parts of images are clipped (cropped). While this does not affect visual parts of images, it may have a minor visual impact because clipped images are re-compressed. Pre-blended images are not clipped.

Returns:
true if clipping images is enabled.

setClipImages

public void setClipImages(boolean bClip)
Clip invisible parts of images.

When enabled, then invisible parts of images are clipped (cropped). While this does not affect visual parts of images, it may have a minor visual impact because clipped images are re-compressed. Pre-blended images are not clipped. Enabling setClipImages will also enable setOptimizeResources(boolean).

Parameters:
bClip - = true will enable image clipping.

getRemoveImages

public boolean getRemoveImages()
Get whether images are removed. When enabled then all images and stencil masks are substituted by empty form XObjects. Inline images are left untouched.

Returns:
true if removing is enabled.

setRemoveImages

public void setRemoveImages(boolean bClip)
Remove images.

When enabled then images and stencil masks are substituted by empty form XObjects. Inline images are left untouched.


getReduceColorComplexity

public boolean getReduceColorComplexity()
Get whether the color complexity of images is reduced. See setReduceColorComplexity(boolean).

Returns:
true if color complexity reduction is enabled.

setReduceColorComplexity

public void setReduceColorComplexity(boolean bClip)
Convert images to their least complex color space.

Images with device color spaces (DeviceRGB, DeviceGray, or DeviceGray) and indexed images with a device color space as base color space are analyzed and if possible converted as follows:

Furthermore, images' masks and soft masks are optimized as follows:

Parameters:
bReduce - = true enables color complexity reduction.

getMrcMaskCompression

public int getMrcMaskCompression()
Get the compression type for MRC masks.

Returns:
the compression type for MRC masks, see NativeLibrary.COMPRESSION

setMrcMaskCompression

public void setMrcMaskCompression(int iCompression)
Set the compression type for MRC masks. See NativeLibrary.COMPRESSION for possible values.

Parameters:
iCompression - the compression type for MRC masks.

getMrcLayerCompression

public int getMrcLayerCompression()
Get the compression type for MRC foreground and background layers.

Returns:
the compression type for MRC layers, see NativeLibrary.COMPRESSION.

setMrcLayerCompression

public void setMrcLayerCompression(int iCompression)
Set the compression type for MRC foreground and background layers. See NativeLibrary.COMPRESSION for possible values.

Parameters:
iCompression - the compression type for MRC foreground and background layers.

getMrcRecognizePictures

public boolean getMrcRecognizePictures()
Get the option to recognize areas of photographic pictures when doing MRC.

Returns:
true if recognizing photographic areas is enabled.

setMrcRecognizePictures

public void setMrcRecognizePictures(boolean bRecognize)
Set the option to recognize areas of photographic pictures when doing MRC.

Parameters:
bRecognize - true to enable the recognition of photographic areas.

getMrcPictCompression

public int getMrcPictCompression()
Get the compression type for MRC cut-out pictures.

Returns:
the compression type for MRC foreground pictures, see NativeLibrary.COMPRESSION

setMrcPictCompression

public void setMrcPictCompression(int iCompression)
Set the compression type for MRC cut-out pictures. See NativeLibrary.COMPRESSION for possible values.

Parameters:
iCompression - the compression type for MRC foreground pictures.

getMrcLayerQuality

public int getMrcLayerQuality()
Get the image quality for MRC foreground and background layers when using a lossy compression type. This is a value between 0 and 100.

Returns:
the currently active compression quality for MRC layers (0..100)

setMrcLayerQuality

public void setMrcLayerQuality(int iQuality)
Set the image quality for MRC foreground and background layers when using a lossy compression type. This is a value between 0 and 100.

Parameters:
iQuality - the new quality value (0..100)

getMrcLayerResolutionDPI

public float getMrcLayerResolutionDPI()
Get the target resolution in DPI for down-sampling MRC foreground and background layers. If set to -1 then no down-sampling is performed.

Returns:
the DPI value to which MRC layers will be downsampled

setMrcLayerResolutionDPI

public void setMrcLayerResolutionDPI(float fResolutionDPI)
Set the target resolution in DPI for down-sampling MRC foreground and background layers. If set to -1 then no down-sampling is performed.

Parameters:
fResolutionDPI - the target resolution in DPI

getExtractImages

public boolean getExtractImages()
Get whether images are extracted. Depending on the compression, the extracted image has one of the following formats: img‹objno›.tif or img ‹objno›.jpg, where ‹objno› is the number of the PDF object of the image.

Returns:
true if image extraction is turned on.

setExtractImages

public void setExtractImages(boolean bExtract)
Images can be extracted to individual image files during processing of the PDF file. Depending on the compression, the extracted image has one of the following formats: img‹objno›.tif or img‹objno›.jpg, where ‹objno› is the number of the PDF object of the image.

Parameters:
bExtract - = true will enable image extraction

getExtractFonts

public boolean getExtractFonts()
Get the switch to extract the embedded fonts.

Depending on the font type, the extracted font has one of the following three formats: fnt‹objno›.ttf or fnt‹objno›.pfb or fnt‹objno›.cff, where ‹objno› is the number of the PDF object of the font.

Returns:
true if fonts are to be extracted.

setExtractFonts

public void setExtractFonts(boolean bExtract)
Set the switch to extract the embedded fonts.

Depending on the font type, the extracted font has one of the following three formats: fnt‹objno›.ttf or fnt‹objno›.pfb or fnt‹objno›.cff, where ‹objno› is the number of the PDF object of the font.

Parameters:
bExtract - true to extract fonts.

getRemoveReduntantObjects

public boolean getRemoveReduntantObjects()
Get whether redundant objects shall be removed. If this property is set to true, duplicate objects are removed in order to reduce the file size.

Returns:
true if redundant objects shall be removed.

setRemoveRedundantObjects

public void setRemoveRedundantObjects(boolean bRemove)
Set whether redundant objects should be removed. If this property is set to true, duplicate objects are removed in order to reduce the file size.

Parameters:
bRemove - true if duplicate objects shall be removed to reduce the file size.

getLinearize

public boolean getLinearize()
Get whether the PDF output file will be linearized, i.e. optimized for fast web access. See setLinearize(boolean).

Returns:
true if output shall be linearized.

setLinearize

public void setLinearize(boolean bLinearize)
Set whether to linearize the PDF output file, i.e. optimize file for fast web access.

A linearized document has a slightly larger file size than a non-linearized file and provides the following main features:

Parameters:
bLinearize - true to linearize the output.

getStrip

public int getStrip()
Get the stripping mode: This mode can be configured to remove unneeded data of a PDF document such as Threads, Metadata, the PieceInfo, the StructTreeRoot entry, embedded Thumbs and the SpiderInfo entry.

Returns:
strip modes.

setStrip

public void setStrip(int iStripModes)
Set the stripping mode: This mode can be configured to remove unneeded data of a PDF document such as Threads, Metadata, the PieceInfo, the StructTreeRoot entry, embedded Thumbs and the SpiderInfo entry. Several values of NativeLibrary.STRIPTYPE can be combined with the bitwise or operator.

Parameters:
iStripModes - strip modes. Valid modes are defined in the NativeLibrary.STRIPTYPE class and can be combined by adding/or-ing.

getFlattenSignatureFields

public boolean getFlattenSignatureFields()
Get whether appearances of signature fields are flattened. See also setFlattenSignatureFields(boolean).

Returns:
true if signature appearances are flattened.

setFlattenSignatureFields

public void setFlattenSignatureFields(boolean bFlatten)
A signature in a PDF consist of two parts:
  1. The invisible digital signature in the PDF
  2. The visual appearance that was attributed to the signature
Part 1 can be used by a viewing application, to verify that a document has not changed since it has been signed and report this to the user. When optimizing a PDF, the PDF is altered and hence the digital signature is broken. Therefore, the 3-Heights(TM) PDF Optimization API removes all signatures, including parts 1 and 2.

When the property bFlatten is set to true, then digital signatures (parts 1) are still removed, but their visual appearances (parts 2) are flattened. I.e. they are retained and drawn as non-editable graphic onto the page.

Note that the resulting PDF can be misleading as it visually appears to be signed, but it has no digital signature and hence, a viewer application does not report any broken signature. In most cases, such a behavior is undesirable.

Parameters:
bFlatten - true to enable flattening of signature appearances.

renameFont

public boolean renameFont(java.lang.String strFontName1,
                          java.lang.String strFontName2)
Deprecated. 

Redefine the font name.

Parameters:
strFontName1 - The font named to be replaced.
strFontName2 - The new font name.
Returns:
true on success.

unembedFont

public boolean unembedFont(java.lang.String strFontName)
Remove an embedded font program. Warning: The output document may not display correctly on certain systems.

Parameters:
strFontName - The name of the font whose font program will be removed.
Returns:
true on success.

getConvertToCFF

public boolean getConvertToCFF()
Get whether embedded Type1 (PostScript) fonts shall be converted to Type1C (Compact Font Format). This reduces the file size.

Returns:
true if Type1 fonts shall be compressed.

setConvertToCFF

public void setConvertToCFF(boolean bConvertToCFF)
Set the switch to convert embedded Type1 (PostScript) fonts to Type1C (Compact Font Format). This reduces the file size.

Parameters:
bConvertToCFF - true to compress fonts.

getColorResolutionDPI

public float getColorResolutionDPI()
Get the target resolution in dots per inch (DPI) after re-sampling images for color images.

Returns:
the resolution value in DPI to which Color images will be downsampled.
See Also:
getResolutionDPI()

setColorResolutionDPI

public void setColorResolutionDPI(float fResolutionDPI)
Set the target resolution in dots per inch (DPI) after re-sampling images for color images.

Parameters:
fResolutionDPI - the target resolution value in DPI to which color images will be downsampled.
See Also:
setResolutionDPI(float)

setColorThresholdDPI

public void setColorThresholdDPI(float fThresholdDPI)
Set the threshold resolution in dots per inch (DPI) to selectively activate re-sampling for color images. Only color images with resolutions exceeding this value will be downsampled.

Parameters:
fThresholdDPI - the new threshold resolution value.
See Also:
setThresholdDPI(float)

getColorThresholdDPI

public float getColorThresholdDPI()
Get the threshold resolution in dots per inch (DPI) for color images.

Returns:
the active threshold resolution value for color images.
See Also:
getThresholdDPI()

getBitonalResolutionDPI

public float getBitonalResolutionDPI()
Get the target resolution in dots per inch (DPI) after re-sampling images for bi-tonal images.

Returns:
the resolution value in DPI to which bi-tonal images will be downsampled
See Also:
getResolutionDPI()

setBitonalResolutionDPI

public void setBitonalResolutionDPI(float fResolutionDPI)
Set the target resolution in dots per inch (DPI) after re-sampling images for bi-tonal images.

Parameters:
fResolutionDPI - the target resolution value in DPI to which bi-tonal images will be downsampled.

setBitonalThresholdDPI

public void setBitonalThresholdDPI(float fThresholdDPI)
Set the threshold resolution in dots per inch (DPI) to selectively activate re-sampling for bi-tonal images. Only bi-tonal images with resolutions exceeding this value will be downsampled.

Parameters:
fThresholdDPI - the new threshold resolution value.

getBitonalThresholdDPI

public float getBitonalThresholdDPI()
Get the threshold resolution in dots per inch (DPI) for bi-tonal images.

Returns:
the active threshold resolution value for bi-tonal images.
See Also:
getThresholdDPI()

getMonochromeResolutionDPI

public float getMonochromeResolutionDPI()
Get the target resolution in dots per inch (DPI) after re-sampling images for monochrome images.

Returns:
the resolution value in DPI to which monochrome images will be downsampled.
See Also:
getThresholdDPI()

setMonochromeResolutionDPI

public void setMonochromeResolutionDPI(float fResolutionDPI)
Set the target resolution in dots per inch (DPI) after re-sampling images for monochrome images.

Parameters:
fResolutionDPI - the target resolution value in DPI to which monochrome images will be downsampled.
See Also:
setResolutionDPI(float)

setMonochromeThresholdDPI

public void setMonochromeThresholdDPI(float fThresholdDPI)
Set the threshold resolution in dots per inch (DPI) to selectively activate re-sampling for monochrome images. Only monochrome images with resolutions exceeding this value will be downsampled.

Parameters:
fThresholdDPI - the new threshold resolution value.

getMonochromeThresholdDPI

public float getMonochromeThresholdDPI()
Get the threshold resolution in dots per inch (DPI) for monochrome images.

Returns:
the active threshold resolution value for monochrome images.

listImages

public boolean listImages(java.lang.String strFileName)
List all images included in the document and write them as a list to a text file.

The list contains the header line: "PageNumber, ObjectNumber, Width, Height, BitsPerComponent, ColorSpace, Resolution, Filter, ImageSize, CompressedSize, CompressionRatio, FileName".

The meanings of these columns are:

Parameters:
strFileName - the name of the output file that saves the list of images.
Returns:
true: The image information was successfully extracted and written to the output text file. false otherwise.

listFonts

public boolean listFonts(java.lang.String strFileName)
List all fonts included in the document and write them as a list to a text file.

The list contains the header line: "FontName, FontType, Encoding, IsCID, IsEmbedded, IsSubsetted, Filename".

The meanings of these columns are:

Parameters:
strFileName - the name of the output file that saves the list of fonts.
Returns:
true: The font information was successfully extracted and written to the output text file. false otherwise.

getSubsetFonts

public boolean getSubsetFonts()
Get whether embedded fonts are subset and embedded font programs of different subsets of the same font merged.

Subsetting refers to removing those glyphs in a font that are not actually used in any text contained in the PDF.

Returns:
true if fonts shall be subset.

setSubsetFonts

public void setSubsetFonts(boolean bSubset)
Subset embedded fonts and merge embedded font programs of different subsets of the same font, granted they can be merged.

Subsetting refers to removing those glyphs in a font that are not actually used in any text contained in the PDF.

Parameters:
bSubset - true to subset fonts.

getMergeEmbeddedFonts

public boolean getMergeEmbeddedFonts()
Get the switch to merge embedded font programs. Font programs can be merged, if they originate from the same font, e.g. they are of the same type, have the same name and encoding. Merging of Type1 (PostScript) and TrueType fonts is supported.

Returns:
true if embedded fonts shall be merged.

setMergeEmbeddedFonts

public void setMergeEmbeddedFonts(boolean bSubset)
Set the switch to merge embedded font programs. Font programs can be merged, if they originate from the same font, e.g. they are of the same type, have the same name and encoding. Merging of Type1 (PostScript) and TrueType fonts is supported.

Parameters:
bSubset - true to merge embedded font programs.

getRemoveStandardFonts

public boolean getRemoveStandardFonts()
Get whether the font programs of all embedded standard fonts shall be removed, such as Arial, Courier, CourierNew, Helvetica, Symbol, Times, TimesNewRoman and ZapfDingbats. See setRemoveStandardFonts(boolean).

Returns:
true to remove the standard fonts.

setRemoveStandardFonts

public void setRemoveStandardFonts(boolean bRemove)
Set whether to remove the font programs of all embedded standard fonts, such as Arial, Courier, CourierNew, Helvetica, Symbol, Times, TimesNewRoman and ZapfDingbats. (A complete list is given in the manual pola.pdf.) The fonts are re-placed with one of the 14 PDF Standard Fonts, all of which have no associated font program. Un-embedding a font decreases the file size.

A PDF Viewer must be able to display these 14 PDF Standard Fonts correctly. Therefore enabling this property usually should not visually alter the PDF when it is displayed.

Un-embedding the font works based on the font's Unicode information. I.e. the un-embedded font's characters are mapped to those of the original font with the same Unicode. Therefore, only fonts with Unicode information will be un-embedded by the 3-Heights™ PDF Optimization API. However, if a font's Unicode information is not correct, un-embedding may lead to visual differences. Whether or not a font's Unicode information is correct can be verified by extracting text that uses the font. Suitable tools for this purpose are for instance the 3-Heights™ PDF Extract Tool or an interactive PDF viewer. If the extracted text is meaningful, the font's Unicode information is correct and unembedding of the font will not lead to visual differences.

Parameters:
bRemove - true to remove the standard fonts

getRemoveNonSymbolicFonts

public boolean getRemoveNonSymbolicFonts()
Deprecated. Deprecated in Version 4.7.


setRemoveNonSymbolicFonts

public void setRemoveNonSymbolicFonts(boolean bRemove)
Deprecated. Deprecated in Version 4.7.


getOptimizeResources

public boolean getOptimizeResources()
Get whether resources shall be optimized. If set, unused resources such as images, fonts, and color spaces are removed. Also content streams are re-built.

Returns:
true to optimize the resources of the output.

setOptimizeResources

public void setOptimizeResources(boolean bOptimize)
Set whether resources should be optimized. If set, unused resources such as images, fonts, and color spaces are removed. Also content streams are re-built.

Parameters:
bOptimize - true to optimize the resources of the output.

getPageCount

public int getPageCount()
Get the number of total pages of the input document. If no document is opened, it returns null.

Returns:
number of pages in the input document.

setVersion

public boolean setVersion(java.lang.String strVersion)
Set the minimum PDF version of the created PDF output file. Supported values for the string are "1.1" to "1.7" (PDF 1.4 corresponds to Acrobat 5, PDF 1.5 to Acrobat 6, etc.).

There are three parameters that influence the version of the PDF output file:

Examples:
  1. Input PDF is version 1.5 and the following settings are applied:
    SetVersion("1.4")
    The output file is PDF version 1.5.
  2. Input PDF is version 1.4 or lower and the following settings are applied:
    SetVersion("1.4")
    The output file is PDF version 1.4.
  3. Input PDF is version 1.3 and the following settings are applied:
    ContinuousCompressions = eComprAttemptJPEG2000
    SetVersion("1.4")
    If the input PDF contains color images to which JPEG2000 compression is applied, the output file will be version 1.5. Otherwise it will be version 1.4.

Returns:
true if version changed successfully.

setInfoEntry

public boolean setInfoEntry(java.lang.String sKey,
                            java.lang.String sValue)
Set the value of an info entry key.

Parameters:
sKey - Key such as Creator, Subject, Keywords etc. or custom attributes.
sValue - The entry's value.

setProfile

public void setProfile(int iProfile)
Set the optimization profile. This implicitly sets many of the optimizer's properties. Please refer to the manual for the exact settings.

Parameters:
iProfile - Valid profiles are defined in NativeLibrary.OPTIMIZATIONPROFILE

linearizeFile

public static boolean linearizeFile(java.lang.String strInFileName,
                                    java.lang.String strPassword,
                                    java.lang.String strOutFileName,
                                    java.lang.String strUserPw,
                                    java.lang.String strOwnerPw,
                                    int iPermissionFlags)
Linearize a PDF file and save the result as a new PDF file, which is optimized for fast web view. This is a stand-alone function and cannot be combined with any other functions or properties.

By default no encryption is used (-1). The permissions that can be granted are listed at the enumeration NativeLibrary.PERMISSION. To not encrypt the output document, set PermissionFlags to ePermNoEncryption (-1), user and owner password to "". In order to allow high quality printing, flags ePermPrint and ePermDigitalPrint need to be set.

Parameters:
strInFileName - The input PDF file name, i.e. the name of document that is read.
strPassword - The user or owner password of the input file name. A password must be provided if the input file is protected by a user password, otherwise an empty string can be passed as argument.
strOutFileName - The output PDF file name, i.e. the name of the linearized document that is written.
strUserPw - The user password of the output PDF file. If this parameter is omitted, the default password is used. Use "" to set no password.
strOwnerPw - The owner password of the output PDF file. If this parameter is omitted, the default password is used. Use "" to set no password.
iPermissionFlags - The permission flags if the document is encrypted and secured by an owner password.