Package com.itextpdf.text.pdf.ocg
Class OCGParser
java.lang.Object
com.itextpdf.text.pdf.ocg.OCGParser
A helper class for OCGRemover.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classClass that processes unknown content.private static classClass that knows how to process graphics state operators.private static classClass that knows how to process inline image operators.private static classClass that knows how to process marked content operators.private static classClass that knows how to process path construction, path painting and path clipping operators.static interfacePDF Operator interface.private static classClass that knows how to process text state operators.private static classClass that knows how to process XObject operators. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteArrayOutputStreamThe OutputStream of this worker object.static final StringConstant used for the default operator.protected intKeeps track of BMC/EMC balance.The OCGs that need to be removed.protected static final Map<String, OCGParser.PdfOperator> A map with all supported operators operators (PDF syntax).protected PdfDictionaryThe OCG properties.The names of XObjects that shouldn't be shown. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidKeeps track of the MarkedContent state.protected voidcheckMarkedContentStart(PdfName ocref) Keeps track of the MarkedContent state.protected booleanChecks if the parser is currently parsing content that needs to be ignored.protected booleanChecks operands to find out if the corresponding operator needs to be present or not.voidparse(PRStream stream, PdfDictionary resources) Parses a stream object and removes OCGs.protected static voidPopulates the operators variable.protected voidWrites a PDF object to the OutputStream, followed by a newline character.protected voidWrites a PDF object to the OutputStream, followed by a space character.protected voidprocess(PdfLiteral operator, List<PdfObject> operands, boolean removable) Processes an operatorprotected static voidprocessOperator(OCGParser parser, PdfLiteral operator, List<PdfObject> operands) Processes an operator.
-
Field Details
-
DEFAULTOPERATOR
Constant used for the default operator.- See Also:
-
operators
A map with all supported operators operators (PDF syntax). -
baos
The OutputStream of this worker object. -
mc_balance
protected int mc_balanceKeeps track of BMC/EMC balance. -
xobj
The names of XObjects that shouldn't be shown. -
ocgs
The OCGs that need to be removed. -
properties
The OCG properties.
-
-
Constructor Details
-
OCGParser
Creates an instance of the OCGParser.- Parameters:
ocgs- a set of String values with the names of the OCGs that need to be removed.
-
-
Method Details
-
parse
Parses a stream object and removes OCGs.- Parameters:
stream- a stream objectresources- the resources dictionary of that object (containing info about the OCGs)- Throws:
IOException
-
processOperator
protected static void processOperator(OCGParser parser, PdfLiteral operator, List<PdfObject> operands) throws Exception Processes an operator.- Parameters:
parser- the parser that needs to process the operatoroperator- the operatoroperands- its operands- Throws:
Exception
-
populateOperators
protected static void populateOperators()Populates the operators variable. -
isVisible
Checks operands to find out if the corresponding operator needs to be present or not.- Parameters:
operands- a list of operands- Returns:
- true if the operators needs to be present.
-
isToRemoved
protected boolean isToRemoved()Checks if the parser is currently parsing content that needs to be ignored.- Returns:
- true if the content needs to be ignored
-
checkMarkedContentStart
Keeps track of the MarkedContent state.- Parameters:
ocref- a reference to an OCG dictionary
-
checkMarkedContentEnd
protected void checkMarkedContentEnd()Keeps track of the MarkedContent state. -
process
protected void process(PdfLiteral operator, List<PdfObject> operands, boolean removable) throws IOException Processes an operator- Parameters:
operator- the operatoroperands- its operandsremovable- is the operator eligable for removal?- Throws:
IOException
-
printsp
Writes a PDF object to the OutputStream, followed by a space character.- Parameters:
o-- Throws:
IOException
-
println
Writes a PDF object to the OutputStream, followed by a newline character.- Parameters:
o-- Throws:
IOException
-