Top Fields Constructors Methods
org.apache.pdfbox.preflight.font

public Class Type3FontValidator

extends FontValidator<Type3Container>
Class Inheritance
Static Imports
org.apache.pdfbox.preflight.PreflightConfiguration.RESOURCES_PROCESS, .PreflightConstants.ERROR_FONTS_DICTIONARY_INVALID, .PreflightConstants.ERROR_FONTS_METRICS, .PreflightConstants.ERROR_FONTS_TYPE3_DAMAGED

Field Summary

Modifier and TypeField and Description
protected final PDType3Font
protected final COSDictionary
Inherited from org.apache.pdfbox.preflight.font.FontValidator:
contextdescriptorHelperfontContainer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
checkCharProcsAndMetrics()

CharProcs is a dictionary where the key is a character name and the value is a Stream which contains the glyph representation of the key.

protected void
checkEncoding()

Overrides org.apache.pdfbox.preflight.font.FontValidator.checkEncoding.

For a Type3 font, the mapping between the Character Code and the Character name is entirely defined in the /Encoding entry.

private void
checkEncodingAsDictionary(COSDictionary
the encoding dictionary.
encodingDictionary
)

This method is called by the CheckEncoding method if the /Encoding entry is an instance of COSDictionary.

private void
checkEncodingAsString(String
The name of the encoding.
enc
)

This method is called by the CheckEncoding method if the /Encoding entry is a String.

private void
checkFontBBox()

Check that the FontBBox element has the right format as declared in the PDF reference document.

private void
checkFontMatrix()

Check that the FontMatrix element has the right format as declared in the PDF reference document.

protected void
private void
checkResources()

If the Resources entry is present, this method checks its content.

private PDType3CharProc
getCharProc(int code)

private float

Returns:

the width of the character
getWidthFromCharProc
(PDType3CharProc charProc)

Parse the Glyph description to obtain the Width

public List<Float>
public void
Inherited from org.apache.pdfbox.preflight.font.FontValidator:
checkToUnicodegetFontContainer

Field Detail

fontback to summary
protected final PDType3Font font
fontDictionaryback to summary
protected final COSDictionary fontDictionary

Constructor Detail

Type3FontValidatorback to summary
public Type3FontValidator(PreflightContext context, PDType3Font font)

Method Detail

checkCharProcsAndMetricsback to summary
private void checkCharProcsAndMetrics()

CharProcs is a dictionary where the key is a character name and the value is a Stream which contains the glyph representation of the key. This method checks that all characters codes defined in the Widths Array exist in the CharProcs dictionary. If the CharProcs doesn't know the Character, it is mapped with the .notdef one. For each character, the Glyph width must be the same as the Width value declared in the Widths array.

checkEncodingback to summary
protected void checkEncoding()

Overrides org.apache.pdfbox.preflight.font.FontValidator.checkEncoding.

For a Type3 font, the mapping between the Character Code and the Character name is entirely defined in the /Encoding entry. The /Encoding Entry can be a Name (For the 5 predefined encodings) or a dictionary. If it is a dictionary, the /Differences array contains the correspondence between a character code and a set of character name which are different from the encoding entry of the dictionary. This method checks that the encoding is :

  • An existing encoding name.
  • A dictionary with an existing encoding name (the name is optional) and a well formed "Differences" array (the array is optional)
Annotations
@Override
checkEncodingAsDictionaryback to summary
private void checkEncodingAsDictionary(COSDictionary encodingDictionary)

This method is called by the CheckEncoding method if the /Encoding entry is an instance of COSDictionary. If that dictionary has a /BaseEncoding entry, the name is checked. In any case, the /Differences array is validated.

Parameters
encodingDictionary:COSDictionary

the encoding dictionary.

checkEncodingAsStringback to summary
private void checkEncodingAsString(String enc)

This method is called by the CheckEncoding method if the /Encoding entry is a String. In this case, the String must be an existing encoding name. (WinAnsi, MacRoman...)

Parameters
enc:String

The name of the encoding.

checkFontBBoxback to summary
private void checkFontBBox()

Check that the FontBBox element has the right format as declared in the PDF reference document.

checkFontMatrixback to summary
private void checkFontMatrix()

Check that the FontMatrix element has the right format as declared in the PDF reference document.

checkMandatoryFieldback to summary
protected void checkMandatoryField()
checkResourcesback to summary
private void checkResources() throws ValidationException

If the Resources entry is present, this method checks its content. Only fonts and images are checked because this resource describes glyphs.

getCharProcback to summary
private PDType3CharProc getCharProc(int code)
getWidthFromCharProcback to summary
private float getWidthFromCharProc(PDType3CharProc charProc) throws IOException

Parse the Glyph description to obtain the Width

Returns:float

the width of the character

getWidthsback to summary
public List<Float> getWidths(PDFont font)
validateback to summary
public void validate() throws ValidationException

Implements abstract org.apache.pdfbox.preflight.font.FontValidator.validate.

Annotations
@Override