Package com.itextpdf.text.pdf.pdfcleanup
Class PdfCleanUpContentOperator
java.lang.Object
com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpContentOperator
- All Implemented Interfaces:
ContentOperator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]protected PdfCleanUpRenderListenerprivate static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]protected ContentOperatorprivate static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprivate floatgetUnscaledTextChunkWidth(PdfCleanUpContentChunk.Text chunk, float characterSpacing, float wordSpacing, float fontSize, float horizontalScaling) We get into this method when the current chunk is not visible.voidinvoke(PdfContentStreamProcessor pdfContentStreamProcessor, PdfLiteral operator, ArrayList<PdfObject> operands) Invokes a content operator.private booleanstatic voidpopulateOperators(PdfContentStreamProcessor contentProcessor, PdfCleanUpRenderListener pdfCleanUpRenderListener) structureTJarray(PdfArray array) Example.private static voidtoPdf(PdfObject object, PdfWriter writer, OutputStream os) Overriding standard PdfObject.toPdf because we need sorted PdfDictionaries.private voidupdateImageStream(PRStream imageStream, byte[] newData) private voidwriteBezierCurve(BezierCurve curve, PdfContentByte canvas) private voidwriteLine(Line line, PdfContentByte canvas) private voidwriteMoveTo(Point2D destinationPoint, PdfContentByte canvas) private voidwriteOperands(PdfContentByte canvas, List<PdfObject> operands) private voidwritePath(Path path, byte[] pathPaintingOperator, PdfContentByte canvas) private voidwritePath(String operatorStr, PdfContentByte canvas, PdfName strokeColorSpace) private voidwriteStroke(PdfContentByte canvas, Path path, PdfName strokeColorSpace) private voidwriteTextChunks(Map<Integer, Float> structuredTJoperands, List<PdfCleanUpContentChunk> chunks, PdfContentByte canvas, float characterSpacing, float wordSpacing, float fontSize, float horizontalScaling) Renders parts of text which are visible.
-
Field Details
-
TStar
private static final byte[] TStar -
Tw
private static final byte[] Tw -
TcTStar
private static final byte[] TcTStar -
TJ
private static final byte[] TJ -
Tc
private static final byte[] Tc -
m
private static final byte[] m -
l
private static final byte[] l -
c
private static final byte[] c -
h
private static final byte[] h -
S
private static final byte[] S -
f
private static final byte[] f -
eoF
private static final byte[] eoF -
n
private static final byte[] n -
W
private static final byte[] W -
eoW
private static final byte[] eoW -
q
private static final byte[] q -
Q
private static final byte[] Q -
cs
private static final byte[] cs -
textShowingOperators
-
pathConstructionOperators
-
strokeOperators
-
nwFillOperators
-
eoFillOperators
-
pathPaintingOperators
-
clippingPathOperators
-
lineStyleOperators
-
strokeColorOperators
-
cleanUpStrategy
-
originalContentOperator
-
-
Constructor Details
-
PdfCleanUpContentOperator
-
-
Method Details
-
populateOperators
public static void populateOperators(PdfContentStreamProcessor contentProcessor, PdfCleanUpRenderListener pdfCleanUpRenderListener) -
invoke
public void invoke(PdfContentStreamProcessor pdfContentStreamProcessor, PdfLiteral operator, ArrayList<PdfObject> operands) throws Exception Description copied from interface:ContentOperatorInvokes a content operator.- Specified by:
invokein interfaceContentOperator- Parameters:
pdfContentStreamProcessor- the processor that is dealing with the PDF contentoperator- the literal PDF syntax of the operatoroperands- the operands that come with the operator- Throws:
Exception- any exception can be thrown - it will be re-packaged into a runtime exception and re-thrown by thePdfContentStreamProcessor
-
writeOperands
- Throws:
IOException
-
allChunksAreVisible
-
toPdf
Overriding standard PdfObject.toPdf because we need sorted PdfDictionaries.- Throws:
IOException
-
structureTJarray
Example. TJ = [(h) 3 4 (q) 7 (w) (e)] Result = {0:0, 1:7, 2:7, 3:0, 4:0}- Returns:
- Map whose key is an ordinal number of the string in the TJ array and value is the position adjustment.
-
writeTextChunks
private void writeTextChunks(Map<Integer, Float> structuredTJoperands, List<PdfCleanUpContentChunk> chunks, PdfContentByte canvas, float characterSpacing, float wordSpacing, float fontSize, float horizontalScaling) throws IOExceptionRenders parts of text which are visible.- Throws:
IOException
-
getUnscaledTextChunkWidth
private float getUnscaledTextChunkWidth(PdfCleanUpContentChunk.Text chunk, float characterSpacing, float wordSpacing, float fontSize, float horizontalScaling) We get into this method when the current chunk is not visible. Here we are calculating a piece of the Tj coefficient for a previous visible chunk. For details see PDF spec., Text Space Details, formula for "tx" coefficient and TextRenderInfo class (getUnscaledBaseline) -
isSpace
-
updateImageStream
private void updateImageStream(PRStream imageStream, byte[] newData) throws BadElementException, IOException, BadPdfFormatException -
writePath
private void writePath(String operatorStr, PdfContentByte canvas, PdfName strokeColorSpace) throws IOException - Throws:
IOException
-
writePath
private void writePath(Path path, byte[] pathPaintingOperator, PdfContentByte canvas) throws IOException - Throws:
IOException
-
writeMoveTo
- Throws:
IOException
-
writeBezierCurve
- Throws:
IOException
-
writeLine
- Throws:
IOException
-
writeStroke
private void writeStroke(PdfContentByte canvas, Path path, PdfName strokeColorSpace) throws IOException - Throws:
IOException
-