Class PreflightStreamEngine
- java.lang.Object
-
- org.apache.pdfbox.contentstream.PDFStreamEngine
-
- org.apache.pdfbox.preflight.content.PreflightStreamEngine
-
- Direct Known Subclasses:
PreflightContentStream,PreflightType3Stream
public abstract class PreflightStreamEngine extends PDFStreamEngine
This class inherits from org.apache.pdfbox.util.PDFStreamEngine to allow the validation of specific rules in ContentStream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPreflightStreamEngine.ColorSpaceType
-
Field Summary
Fields Modifier and Type Field Description protected PreflightContextcontextprotected PDPageprocessedPage
-
Constructor Summary
Constructors Constructor Description PreflightStreamEngine(PreflightContext context, PDPage page)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckColorOperators(java.lang.String operation)This method validates if the ColorOperator can be used with the color space defined in OutputIntent dictionaries.protected voidcheckSetColorSpaceOperators(Operator operator, java.util.List<COSBase> arguments)This method validates if the ColorSpace used as operand is consistent with the color space defined in OutputIntent dictionaries.private PDColorSpacegetColorSpace(java.lang.String operation)private ColorSpaceHelpergetColorSpaceHelper(PDColorSpace pdCS)private booleanisDeviceIndependent(PDColorSpace cs, PreflightStreamEngine.ColorSpaceType expectedIccType)protected voidregisterError(java.lang.String msg, java.lang.String errorCode)Add a validation error into the PreflightContextprotected voidregisterError(java.lang.String msg, java.lang.String errorCode, boolean warning)voidregisterError(java.lang.String msg, java.lang.String errorCode, boolean warning, java.lang.Throwable cause)voidregisterError(java.lang.String msg, java.lang.String errorCode, java.lang.Throwable cause)private COSBasetoLongName(COSBase cs)(package private) voidvalidateDefaultColorSpace(Operator operator)In some cases, the colorspace isn't checked because defaults (/DeviceGray) is used.protected voidvalidateInlineImageColorSpace(Operator operator)This method validates if the ColorSpace used by the InlinedImage is consistent with the color space defined in OutputIntent dictionaries.protected voidvalidateInlineImageFilter(Operator operator)Throw a ContentStreamException if the LZW filter is used in a InlinedImage.protected voidvalidateNumberOfGraphicStates(Operator operator)Valid the number of graphic states if the operator is the Save Graphic state operator ("q")protected voidvalidateRenderingIntent(Operator operator, java.util.List<COSBase> arguments)Check operands of the "ri" operator.private booleanvalidColorSpace(PDColorSpace colorSpace, PreflightStreamEngine.ColorSpaceType expectedIccType)private booleanvalidColorSpaceDestOutputProfile(PreflightStreamEngine.ColorSpaceType expectedType)-
Methods inherited from class org.apache.pdfbox.contentstream.PDFStreamEngine
addOperator, applyTextAdjustment, beginMarkedContentSequence, beginText, decreaseLevel, endMarkedContentSequence, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, isShouldProcessColorOperators, markedContentPoint, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processPage, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showForm, showGlyph, showText, showTextString, showTextStrings, showTransparencyGroup, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
-
-
-
-
Field Detail
-
context
protected PreflightContext context
-
processedPage
protected PDPage processedPage
-
-
Constructor Detail
-
PreflightStreamEngine
public PreflightStreamEngine(PreflightContext context, PDPage page)
-
-
Method Detail
-
validateRenderingIntent
protected void validateRenderingIntent(Operator operator, java.util.List<COSBase> arguments) throws ContentStreamException
Check operands of the "ri" operator. Operands must exist in the RenderingIntent list. (org.apache.pdfbox.preflight.utils.RenderingIntents)- Parameters:
operator- the "ri" operatorarguments- the "ri" operands- Throws:
ContentStreamException- ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY if the operand is invalid
-
validateNumberOfGraphicStates
protected void validateNumberOfGraphicStates(Operator operator)
Valid the number of graphic states if the operator is the Save Graphic state operator ("q")- Parameters:
operator-
-
validateInlineImageFilter
protected void validateInlineImageFilter(Operator operator)
Throw a ContentStreamException if the LZW filter is used in a InlinedImage.- Parameters:
operator- the InlinedImage object (BI to EI)
-
validateInlineImageColorSpace
protected void validateInlineImageColorSpace(Operator operator) throws java.io.IOException
This method validates if the ColorSpace used by the InlinedImage is consistent with the color space defined in OutputIntent dictionaries.- Parameters:
operator- the InlinedImage object (BI to EI)- Throws:
java.io.IOException
-
getColorSpaceHelper
private ColorSpaceHelper getColorSpaceHelper(PDColorSpace pdCS)
-
checkColorOperators
protected void checkColorOperators(java.lang.String operation) throws ContentStreamExceptionThis method validates if the ColorOperator can be used with the color space defined in OutputIntent dictionaries.- Parameters:
operation- the color operator- Throws:
ContentStreamException
-
validateDefaultColorSpace
void validateDefaultColorSpace(Operator operator) throws ContentStreamException
In some cases, the colorspace isn't checked because defaults (/DeviceGray) is used. Thus we need to check all text output, stroke and fill for /DeviceGray.- Parameters:
operator- an operator.- Throws:
ContentStreamException
-
validColorSpace
private boolean validColorSpace(PDColorSpace colorSpace, PreflightStreamEngine.ColorSpaceType expectedIccType) throws ContentStreamException
- Throws:
ContentStreamException
-
validColorSpaceDestOutputProfile
private boolean validColorSpaceDestOutputProfile(PreflightStreamEngine.ColorSpaceType expectedType) throws ContentStreamException
- Throws:
ContentStreamException
-
isDeviceIndependent
private boolean isDeviceIndependent(PDColorSpace cs, PreflightStreamEngine.ColorSpaceType expectedIccType)
-
getColorSpace
private PDColorSpace getColorSpace(java.lang.String operation)
-
checkSetColorSpaceOperators
protected void checkSetColorSpaceOperators(Operator operator, java.util.List<COSBase> arguments) throws java.io.IOException
This method validates if the ColorSpace used as operand is consistent with the color space defined in OutputIntent dictionaries.- Parameters:
operator-arguments-- Throws:
java.io.IOException
-
registerError
protected void registerError(java.lang.String msg, java.lang.String errorCode)Add a validation error into the PreflightContext- Parameters:
msg- exception detailserrorCode- the error code.
-
registerError
public void registerError(java.lang.String msg, java.lang.String errorCode, java.lang.Throwable cause)
-
registerError
protected void registerError(java.lang.String msg, java.lang.String errorCode, boolean warning)
-
registerError
public void registerError(java.lang.String msg, java.lang.String errorCode, boolean warning, java.lang.Throwable cause)
-
-