com.crionics.jpdf
Class Preferences

java.lang.Object
  extended by com.crionics.jpdf.Preferences
All Implemented Interfaces:
java.lang.Cloneable

public final class Preferences
extends java.lang.Object
implements java.lang.Cloneable

This class can be used to custumoze the PDF generation attributes.


Field Summary
static int ENCRYPTION_AES
          AES-128 Encryption, only supported by PDF 1.6 (Acrobat 7)
static int ENCRYPTION_NONE
          No Encryption setting
static int ENCRYPTION_RC4
          RC4 Encryption
static int FORMAT_G3CCITT
           
static int FORMAT_G4CCITT
           
static int FORMAT_GZIP
           
static int FORMAT_JPEG
           
static int FORMAT_RAW
           
static int FORMAT_UNCHANGED
           
 ICredentials openCredentials
           
 RenderingParameters params
           
static int PDFFORMAT_COMPATIBLE
          The standard legacy format.
static int PDFFORMAT_PURE
          Starting with Acrobat 6, Adobe introduced a new format aimed at compressing the document size further.
static int SECURITY_CERTIFICATE_PROTECTED
           
static int SECURITY_NONE
           
static int SECURITY_PASSWORD_PROTECTED
           
static int SIGN_COMPATIBLE
          Comaptible signature are generated with a pkcs7.detached filter This format is compatible with Verisign
static int SIGN_LEGACY
          Raw signature format are generated with a x509.xxxxx filter
static int SIGN_WINDOWS
          Windows signature are generated with a pkcs7.sha1 filter
 
Constructor Summary
Preferences()
           
 
Method Summary
 java.lang.Object clone()
           
 int getBlackAndWhiteImageCompression()
          Returns the compression algorithm used for Black and white graphics Typical values are:
FORMAT_G3CCITT
FORMAT_G4CCITT
FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW
FORMAT_UNCHANGED
 int getColorAndGrayscaleImageCompression()
          Returns the compression algorithm used for color and gray graphics.
 ICredentialsCreation getDefaultCredentials()
           
 int getDefaultEncryptionKeyLength()
          returns the key length used to cipher the document.
 int getDefaultEncryptionType()
          return the encryption type used to protect the document
any of
ENCRYPTION_NONE no encryption
ENCRYPTION_RC4 standard encryption, 40 and 128 bits long.
 java.awt.print.PageFormat getDefaultPageFormat()
          Returns the default page size in use when new pages are appended.
 int getDefaultPDFFormat()
          return true if document is generated for Acrobat 6+ only
 float getDefaultPDFVersion()
          Returns the default PDF Version for new documents or made out of an existing one.
 int getDefaultSecurityType()
          Return how the document is protected. any of:
SECURITY_NONE
SECURITY_PASSWORD_PROTECTED
SECURITY_CERTIFICATE_PROTECTED
default:SECURITY_NONE This setting is used at document creation.
 int getDefaultSignatureType()
           
 java.lang.String getJceProvider()
          gets the JCE Name than in use internally.
 int getLoosyCompressionQuality()
          Returns the compression quality for loosy image compressions
 boolean getShowAuthenticationGUI()
          return true if a dialog is displayed to request the authorization credentials.
 int getTabSize()
          Sets the number of Space character to use when drawing Text containing Tabulation characters.
 boolean isCompressed()
          Returns true if the document is compressed
 boolean isDownSampleImages()
          Images are typically smaller or bigger than showed on a pdf pages.
 boolean isGenerateAnnotations()
          return true if jpdf renders the pdf annotations.
 boolean isGenerateStringsAsGlyph()
          Forces jPDF to render strings as Glyphs, it makes documents bigger but forbids copy/paste as well as text ripping.
 boolean isUseObjectStreams()
          This flag only makes sense if setPurePDF15 is true. it forces the engine to store objects in object streams. the default is TRUE.
 void setBlackAndWhiteImageCompression(int bwAlgorithm)
          Select the compression algorithm for B&W pictures defaults to FORMAT_GZIP
Typical values are:
FORMAT_G3CCITT
FORMAT_G4CCITT
FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW
FORMAT_UNCHANGED
 void setColorAndGrayscaleImageCompression(int colorAlgorithm)
          Select the compression algorithm for color pictures defaults to FORMAT_GZIP
Typical values are:
FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW
 void setCompressed(boolean compress)
          Should the output be compressed default is true;
 void setDefaultCredentials(ICredentialsCreation credentials)
           
 void setDefaultEncryptionKeyLength(int theKeyLength)
          Sets the key length used to cipher the document
 void setDefaultEncryptionType(int encryptionType)
          This setting is used at document creation.
 void setDefaultPageFormat(java.awt.print.PageFormat pageSize)
          Sets the default page size in use when new pages are created.
 void setDefaultPDFFormat(int format)
          Forces the parser to generate documents using the new format introduced with Acrobat 6 (PDF 1.5).
 void setDefaultPDFVersion(float version)
          Sets the default PDF Version for new documents.This property applies only when a new document is created.
 void setDefaultSecurityType(int securityType)
           
 void setDefaultSignatureType(int signLevel)
          The parameter controls what kind of PDF signature is built in the document.
 void setDownSampleImages(boolean downSample)
          Should images be resized or down sampled.
 void setGenerateAnnotations(boolean isGenerateAnnotations)
          jPDF renders annotations when this flag is set to true
 void setGenerateStringsAsGlyph(boolean thedrawStringsAsGlyph)
          Tells jPDF Creator if it must create String as a caracter string or as a Glyph
 void setJceProvider(java.lang.String provider)
          Sets the JCE Name than must be used internally.
 void setLoosyCompressionQuality(int theQuality)
          Sets the quality used by loosy compression algorithms such as JPEG
 void setShowAuthenticationGUI(boolean showAuthenticationGUI)
          Sets if jPDF should display a dialog to request authorization credentials.
 void setTabSize(int value)
          Sets the number of Space character to use when drawing Text containing Tabulation characters.
 void setUseObjectStreams(boolean isUseObjectStreams)
          Sets the setting which controls how the parser stores objects in the documents.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCRYPTION_AES

public static final int ENCRYPTION_AES
AES-128 Encryption, only supported by PDF 1.6 (Acrobat 7)

See Also:
Constant Field Values

ENCRYPTION_NONE

public static final int ENCRYPTION_NONE
No Encryption setting

See Also:
Constant Field Values

ENCRYPTION_RC4

public static final int ENCRYPTION_RC4
RC4 Encryption

See Also:
Constant Field Values

FORMAT_G3CCITT

public static final int FORMAT_G3CCITT
See Also:
Constant Field Values

FORMAT_G4CCITT

public static final int FORMAT_G4CCITT
See Also:
Constant Field Values

FORMAT_GZIP

public static final int FORMAT_GZIP
See Also:
Constant Field Values

FORMAT_JPEG

public static final int FORMAT_JPEG
See Also:
Constant Field Values

FORMAT_RAW

public static final int FORMAT_RAW
See Also:
Constant Field Values

FORMAT_UNCHANGED

public static final int FORMAT_UNCHANGED
See Also:
Constant Field Values

PDFFORMAT_COMPATIBLE

public static final int PDFFORMAT_COMPATIBLE
The standard legacy format.

See Also:
Constant Field Values

PDFFORMAT_PURE

public static final int PDFFORMAT_PURE
Starting with Acrobat 6, Adobe introduced a new format aimed at compressing the document size further. Using this format makes documents typically 20-30% smaller but can only be read by reader which support it.

See Also:
Constant Field Values

SECURITY_CERTIFICATE_PROTECTED

public static final int SECURITY_CERTIFICATE_PROTECTED
See Also:
Constant Field Values

SECURITY_NONE

public static final int SECURITY_NONE
See Also:
Constant Field Values

SECURITY_PASSWORD_PROTECTED

public static final int SECURITY_PASSWORD_PROTECTED
See Also:
Constant Field Values

SIGN_COMPATIBLE

public static final int SIGN_COMPATIBLE
Comaptible signature are generated with a pkcs7.detached filter This format is compatible with Verisign

See Also:
Constant Field Values

SIGN_LEGACY

public static final int SIGN_LEGACY
Raw signature format are generated with a x509.xxxxx filter

See Also:
Constant Field Values

SIGN_WINDOWS

public static final int SIGN_WINDOWS
Windows signature are generated with a pkcs7.sha1 filter

See Also:
Constant Field Values

openCredentials

public ICredentials openCredentials

params

public RenderingParameters params
Constructor Detail

Preferences

public Preferences()
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getBlackAndWhiteImageCompression

public int getBlackAndWhiteImageCompression()
Returns the compression algorithm used for Black and white graphics Typical values are:
FORMAT_G3CCITT
FORMAT_G4CCITT
FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW
FORMAT_UNCHANGED

Returns:
the compression algorithm used for Black and white graphics

getColorAndGrayscaleImageCompression

public int getColorAndGrayscaleImageCompression()
Returns the compression algorithm used for color and gray graphics. Typical values are: FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW
FORMAT_UNCHANGED

Returns:
the compression algorithm used for color and gray graphics

getDefaultCredentials

public ICredentialsCreation getDefaultCredentials()

getDefaultEncryptionKeyLength

public int getDefaultEncryptionKeyLength()
returns the key length used to cipher the document. This setting is used at document creation.

Returns:
the key length used to cipher the document in bits

getDefaultEncryptionType

public int getDefaultEncryptionType()
return the encryption type used to protect the document
any of
ENCRYPTION_NONE no encryption
ENCRYPTION_RC4 standard encryption, 40 and 128 bits long.
ENCRYPTION_AES128 strong encryption, only supported by pdf 1.6+

default ENCRYPTION_NONE. This setting is used at document creation.

Returns:
the encryption type used to protect the document

getDefaultPageFormat

public java.awt.print.PageFormat getDefaultPageFormat()
Returns the default page size in use when new pages are appended.

Returns:
the default page size in use when new pages are appended.

getDefaultPDFFormat

public int getDefaultPDFFormat()
return true if document is generated for Acrobat 6+ only

Returns:
true if document is generated for Acrobat 6+ only

getDefaultPDFVersion

public float getDefaultPDFVersion()
Returns the default PDF Version for new documents or made out of an existing one.

Returns:
the pdf document version

getDefaultSecurityType

public int getDefaultSecurityType()
Return how the document is protected. any of:
SECURITY_NONE
SECURITY_PASSWORD_PROTECTED
SECURITY_CERTIFICATE_PROTECTED
default:SECURITY_NONE This setting is used at document creation.

Returns:
how the document is protected.

getDefaultSignatureType

public int getDefaultSignatureType()

getJceProvider

public java.lang.String getJceProvider()
gets the JCE Name than in use internally. Typically, "BC" or "SUN".

Returns:
the JCE provider in use, if null, let the JVM pick the correct JCE.

getLoosyCompressionQuality

public int getLoosyCompressionQuality()
Returns the compression quality for loosy image compressions

Returns:
The compression quality for loosy image compressions

getShowAuthenticationGUI

public boolean getShowAuthenticationGUI()
return true if a dialog is displayed to request the authorization credentials.

Returns:
if true, a dialog is displayed when the credentials are invalid
if false, a PdfAuthException is raised.

getTabSize

public int getTabSize()
Sets the number of Space character to use when drawing Text containing Tabulation characters.

Returns:
The number of Space character to use

isCompressed

public boolean isCompressed()
Returns true if the document is compressed

Returns:
true if the document is compressed

isDownSampleImages

public boolean isDownSampleImages()
Images are typically smaller or bigger than showed on a pdf pages. For those bigger, jpdf can reduce the file size by down sample the image.

Returns:
true is the images are downsampled

isGenerateAnnotations

public boolean isGenerateAnnotations()
return true if jpdf renders the pdf annotations.

Returns:
true if jpdf renders the pdf annotations.

isGenerateStringsAsGlyph

public boolean isGenerateStringsAsGlyph()
Forces jPDF to render strings as Glyphs, it makes documents bigger but forbids copy/paste as well as text ripping. It also makes sure the font is rendered properly.

Returns:
true if jPDF creates Strings as glyph

isUseObjectStreams

public boolean isUseObjectStreams()
This flag only makes sense if setPurePDF15 is true. it forces the engine to store objects in object streams. the default is TRUE. Internally the flag may be set to false to perform document merges.

Returns:
true if the parser can use objectstreams

setBlackAndWhiteImageCompression

public void setBlackAndWhiteImageCompression(int bwAlgorithm)
                                      throws PdfException
Select the compression algorithm for B&W pictures defaults to FORMAT_GZIP
Typical values are:
FORMAT_G3CCITT
FORMAT_G4CCITT
FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW
FORMAT_UNCHANGED

Parameters:
bwAlgorithm - a constant representing the algorithm to use
Throws:
PdfException - parameter validation error

setColorAndGrayscaleImageCompression

public void setColorAndGrayscaleImageCompression(int colorAlgorithm)
                                          throws PdfException
Select the compression algorithm for color pictures defaults to FORMAT_GZIP
Typical values are:
FORMAT_GZIP
FORMAT_JPEG
FORMAT_RAW

Parameters:
colorAlgorithm - a constant representing the algorithm to use.
Throws:
PdfException - parameter validation error

setCompressed

public void setCompressed(boolean compress)
Should the output be compressed default is true;

Parameters:
compress - a boolean value

setDefaultCredentials

public void setDefaultCredentials(ICredentialsCreation credentials)

setDefaultEncryptionKeyLength

public void setDefaultEncryptionKeyLength(int theKeyLength)
                                   throws PdfException
Sets the key length used to cipher the document

Parameters:
theKeyLength - size in bits of the key (defaults to 40), must be a multiple of 8
Throws:
PdfException - parameter validation error

setDefaultEncryptionType

public void setDefaultEncryptionType(int encryptionType)
                              throws PdfException
This setting is used at document creation.

Parameters:
encryptionType -
Throws:
PdfException

setDefaultPageFormat

public void setDefaultPageFormat(java.awt.print.PageFormat pageSize)
Sets the default page size in use when new pages are created.

Parameters:
pageSize - the default page size for new pages

setDefaultPDFFormat

public void setDefaultPDFFormat(int format)
                         throws PdfException
Forces the parser to generate documents using the new format introduced with Acrobat 6 (PDF 1.5). Using the new format documents are usually smaller than their legacy equivalents.

Parameters:
format - true if document is generated for Acrobat 6+ only
Throws:
PdfException

setDefaultPDFVersion

public void setDefaultPDFVersion(float version)
Sets the default PDF Version for new documents.This property applies only when a new document is created. If you need to change the current document version please use PdfDocumentDescription.setPdfVersion()

Parameters:
version - the new document version or null to reset the property to its builtin defaults.

setDefaultSecurityType

public void setDefaultSecurityType(int securityType)
                            throws PdfException
Throws:
PdfException

setDefaultSignatureType

public void setDefaultSignatureType(int signLevel)
                             throws PdfException
The parameter controls what kind of PDF signature is built in the document.
SIGN_LEGACY will use a adbe.x509 filter supported by all versions of acrobat, even the oldest ones.
SIGN_COMPATIBLE uses the defacto PKI standard pkcs7 to encode the signature information
SIGN_WINDOWS uses Windows certificate to encode the signature information

Parameters:
signLevel - the signature level to create
Throws:
PdfException - parameter validation errorss

setDownSampleImages

public void setDownSampleImages(boolean downSample)
Should images be resized or down sampled. This greatly improves file size.
default is false

Parameters:
downSample - true to downsample images

setGenerateAnnotations

public void setGenerateAnnotations(boolean isGenerateAnnotations)
jPDF renders annotations when this flag is set to true

Parameters:
isGenerateAnnotations - true to let jPDF render the annotations.

setGenerateStringsAsGlyph

public void setGenerateStringsAsGlyph(boolean thedrawStringsAsGlyph)
Tells jPDF Creator if it must create String as a caracter string or as a Glyph


setJceProvider

public void setJceProvider(java.lang.String provider)
Sets the JCE Name than must be used internally. Typically, "BC" or "SUN". if null, let the JVM pick the correct JCE.

Parameters:
provider - a unique JCE identifier

setLoosyCompressionQuality

public void setLoosyCompressionQuality(int theQuality)
Sets the quality used by loosy compression algorithms such as JPEG

Parameters:
theQuality - an integer for 0 to 100 used to specify the image quality (only applies to JPG compression)

setShowAuthenticationGUI

public void setShowAuthenticationGUI(boolean showAuthenticationGUI)
Sets if jPDF should display a dialog to request authorization credentials. If the inserted password is invalid, a PdfAuthException is then raised.

Parameters:
showAuthenticationGUI - if true, a dialog is displayed when the credentials are invalid
if false, a PdfAuthException is raised.

setTabSize

public void setTabSize(int value)
Sets the number of Space character to use when drawing Text containing Tabulation characters.
Default value = 4

Parameters:
value - The number of Space character to use

setUseObjectStreams

public void setUseObjectStreams(boolean isUseObjectStreams)
Sets the setting which controls how the parser stores objects in the documents. ObjectStreams were introduces with PDF 1.5, they provide a way to compress document with a better compression ratio. However in certain situations (especially merging) it is required to disable them.s

Parameters:
isUseObjectStreams - true if the parser can use objectstreams


Copyright © 1999-2007 Crionics. All Rights Reserved.