Package org.apache.pdfbox.preflight.font
Class Type3FontValidator
- java.lang.Object
-
- org.apache.pdfbox.preflight.font.FontValidator<Type3Container>
-
- org.apache.pdfbox.preflight.font.Type3FontValidator
-
public class Type3FontValidator extends FontValidator<Type3Container>
-
-
Field Summary
Fields Modifier and Type Field Description protected COSDocument
cosDocument
protected PDType3Font
font
protected COSDictionary
fontDictionary
-
Fields inherited from class org.apache.pdfbox.preflight.font.FontValidator
context, descriptorHelper, fontContainer
-
-
Constructor Summary
Constructors Constructor Description Type3FontValidator(PreflightContext context, PDType3Font font)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
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 encodingDictionary)
This method is called by the CheckEncoding method if the /Encoding entry is an instance of COSDictionary.private void
checkEncodingAsString(java.lang.String 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
checkMandatoryField()
private void
checkResources()
If the Resources entry is present, this method checks its content.private PDType3CharProc
getCharProc(int code)
private float
getWidthFromCharProc(PDType3CharProc charProc)
Parse the Glyph description to obtain the Widthjava.util.List<java.lang.Float>
getWidths(PDFont font)
void
validate()
-
Methods inherited from class org.apache.pdfbox.preflight.font.FontValidator
checkToUnicode, getFontContainer
-
-
-
-
Field Detail
-
font
protected PDType3Font font
-
fontDictionary
protected COSDictionary fontDictionary
-
cosDocument
protected COSDocument cosDocument
-
-
Constructor Detail
-
Type3FontValidator
public Type3FontValidator(PreflightContext context, PDType3Font font)
-
-
Method Detail
-
validate
public void validate() throws ValidationException
- Specified by:
validate
in classFontValidator<Type3Container>
- Throws:
ValidationException
-
checkMandatoryField
protected void checkMandatoryField()
-
checkFontBBox
private void checkFontBBox()
Check that the FontBBox element has the right format as declared in the PDF reference document.
-
checkFontMatrix
private void checkFontMatrix()
Check that the FontMatrix element has the right format as declared in the PDF reference document.
-
checkEncoding
protected void 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)
- Overrides:
checkEncoding
in classFontValidator<Type3Container>
-
checkEncodingAsString
private void checkEncodingAsString(java.lang.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
- The name of the encoding.
-
checkEncodingAsDictionary
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
- the encoding dictionary.
-
checkCharProcsAndMetrics
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.
-
getWidths
public java.util.List<java.lang.Float> getWidths(PDFont font)
-
getCharProc
private PDType3CharProc getCharProc(int code)
-
getWidthFromCharProc
private float getWidthFromCharProc(PDType3CharProc charProc) throws java.io.IOException
Parse the Glyph description to obtain the Width- Returns:
- the width of the character
- Throws:
java.io.IOException
-
checkResources
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.- Throws:
ValidationException
-
-