com.qoppa.pdf.errors
Class PDFErrorHandling

java.lang.Object
  extended by com.qoppa.pdf.errors.PDFErrorHandling

public class PDFErrorHandling
extends Object

This class is used to set different error handling options within the PDF library. With the methods in this class, the host application can tell the library whether to display an error in the rendering of a page or to abort the entire rendering operation. Additionally, The class has methods for the library to keep track of errors and for the host application to get the list of errors in the last rendering operation.

Author:
Qoppa Software

Field Summary
static int EH_ABORT_RENDERING
          Abort the entire rendering operation and throw an exception to the host application.
static int EH_SHOW_ERROR_AND_CONTINUE
          Display the error in the rendering of the page and continue rendering other pages.
 
Constructor Summary
PDFErrorHandling()
           
 
Method Summary
static void addError(RenderError error)
          Add an error to the list of errors accumulated.
static void addError(Throwable t, String prefixMsg)
          Add an error to the list of errors accumulated.
static void checkForErrors_UsePDFException(String errorMsg)
          This is a convenience method that gets called by the library after a rendering.
static void checkForErrors_UsePrinterException(String errorMsg)
          This is a convenience method that gets called by the library after printing a page.
static void clearErrors()
          Clear any errors that have accumulated from previous pages.
static int getErrorHandling()
          Returns the current value of the error handling flag.
static Vector getErrors()
          Gets a list of errors in the last rendering.
static boolean isThrowXFADynamicException()
          Returns the value of the flag that controls whether or not an exception is thrown when trying to build a document with an AcroForm that has Adobe XML Forms Architecture (XFA) data, and is a Dynamic Form.
static boolean isUseSubstituteFont()
          Returns the value of the flag that controls font handling errors.
static void setErrorHandling(int errorHandling)
          Sets the value of the error handling flag.
static void setThrowXFADynamicException(boolean throwDynamicXFAException)
          When the flag is set to true (the default), the library will throw an error if the document being built has an AcroForm that has Adobe XML Forms Architecture (XFA) data, and is a Dynamic Form.
static void setUseSubstituteFont(boolean useSubstituteFont)
          Use substitute fonts when there is an error.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EH_SHOW_ERROR_AND_CONTINUE

public static final int EH_SHOW_ERROR_AND_CONTINUE
Display the error in the rendering of the page and continue rendering other pages.

See Also:
Constant Field Values

EH_ABORT_RENDERING

public static final int EH_ABORT_RENDERING
Abort the entire rendering operation and throw an exception to the host application.

See Also:
Constant Field Values
Constructor Detail

PDFErrorHandling

public PDFErrorHandling()
Method Detail

clearErrors

public static void clearErrors()
Clear any errors that have accumulated from previous pages. This method is called by any page rendering operations within the library.


addError

public static void addError(RenderError error)
Add an error to the list of errors accumulated. This method is called by the internal classes in the library anytime there is an error rendering an element in a PDF page (such as an error on an image or in a font).

Parameters:
error - The error.

addError

public static void addError(Throwable t,
                            String prefixMsg)
Add an error to the list of errors accumulated. This method is called by the internal classes in the library anytime there is an error rendering an element in a PDF page (such as an error on an image or in a font). THis is a convenience method that takes an exception and an error message and then creates a RenderError object to add to the error list.

Parameters:
t - The exception that was thrown.
prefixMsg - A message to prefix to error string.

getErrors

public static Vector getErrors()
Gets a list of errors in the last rendering. This method can be called by the host application after a rendering when the error handling is set to EH_SHOW_ERROR_AND_CONTINUE to find out if there were any errors in the rendering.

Returns:
A list of errors.

checkForErrors_UsePrinterException

public static void checkForErrors_UsePrinterException(String errorMsg)
                                               throws PrinterException
This is a convenience method that gets called by the library after printing a page. If there were errors when printing the page, and error handling is set to EH_ABORT_PAGE, the method throws a PrinterException.

Parameters:
errorMsg - The error message to use in the PrinterException.
Throws:
PrinterException

checkForErrors_UsePDFException

public static void checkForErrors_UsePDFException(String errorMsg)
                                           throws PDFException
This is a convenience method that gets called by the library after a rendering. If there were errors when rendering the contents of a page, and error handling is set to EH_ABORT_RENDERING, the method throws a PDFException, thereby aborting the entire rendering of the document.

Parameters:
errorMsg - The error message to use in the PDFException.
Throws:
PDFException

getErrorHandling

public static int getErrorHandling()
Returns the current value of the error handling flag.

Returns:
The current value of the error handling flag. This value can be either EH_SHOW_ERROR_AND_CONTINUE or EH_ABORT_RENDERING.

setErrorHandling

public static void setErrorHandling(int errorHandling)
Sets the value of the error handling flag. THis can be either EH_SHOW_ERROR_AND_CONTINUE or EH_ABORT_RENDERING.

Parameters:
errorHandling - The new value of the error handling flag.

isUseSubstituteFont

public static boolean isUseSubstituteFont()
Returns the value of the flag that controls font handling errors.

Returns:
Boolean flag that indicates whether substitute fonts should be used.

setUseSubstituteFont

public static void setUseSubstituteFont(boolean useSubstituteFont)
Use substitute fonts when there is an error. When the flag is set to false (the default), the library will throw an error if a font is missing or if there is a problem creating an embedded font. If the flag is true, the library will use a default substitute font to replace the font with which there is an error.

Use this flag only if you know the contents of your PDF well. The substituted font might have an entirely different character set resulting in "garbage" displayed on the screen anyways.

Parameters:
useSubstituteFont - The new value of the flag.

isThrowXFADynamicException

public static boolean isThrowXFADynamicException()
Returns the value of the flag that controls whether or not an exception is thrown when trying to build a document with an AcroForm that has Adobe XML Forms Architecture (XFA) data, and is a Dynamic Form.

Returns:
Boolean flag that indicates whether to throw an exception on documents with a Dynamic Form.

setThrowXFADynamicException

public static void setThrowXFADynamicException(boolean throwDynamicXFAException)
When the flag is set to true (the default), the library will throw an error if the document being built has an AcroForm that has Adobe XML Forms Architecture (XFA) data, and is a Dynamic Form. If the flag is false, there will be no error.

Parameters:
throwDynamicXFAException - The new value of the flag.