/**
* Writes parts of text which are visible into a content stream.
*/
private void WriteTextChunks(IDictionary<int, float> structuredTJoperands, IList<PdfCleanUpContentChunk> chunks, PdfContentByte canvas,
float characterSpacing, float wordSpacing, float fontSize, float horizontalScaling) {
canvas.SetCharacterSpacing(0);
canvas.SetWordSpacing(0);
canvas.InternalBuffer.Append((byte) '[');
float convertedCharacterSpacing = -characterSpacing * 1000f / fontSize;
float convertedWordSpacing = -wordSpacing * 1000f / fontSize;
float shift = structuredTJoperands != null ? structuredTJoperands[0] : 0;
PdfCleanUpContentChunk.Text prevChunk = null;
foreach (PdfCleanUpContentChunk chunk in chunks) {
PdfCleanUpContentChunk.Text textChunk = (PdfCleanUpContentChunk.Text) chunk;
if (prevChunk != null && prevChunk.NumOfStrTextBelongsTo != textChunk.NumOfStrTextBelongsTo &&
structuredTJoperands != null) {
shift += structuredTJoperands[prevChunk.NumOfStrTextBelongsTo];
}
if (textChunk.Visible) {
if (Util.compare(shift, 0.0f) != 0 && Util.compare(shift, -0.0f) != 0) {
canvas.InternalBuffer.Append(shift).Append(' ');
}
textChunk.GetText().ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
canvas.InternalBuffer.Append(' ');
shift = convertedCharacterSpacing + (IsSpace(textChunk) ? convertedWordSpacing : 0);
} else {
shift += GetUnscaledTextChunkWidth(textChunk, characterSpacing, wordSpacing,
fontSize, horizontalScaling);
}
prevChunk = textChunk;
}
if (Util.compare(shift, 0) != 0 && Util.compare(shift, -0.0f) != 0) {
canvas.InternalBuffer.Append(shift);
}
canvas.InternalBuffer.Append(TJ);
if (Util.compare(characterSpacing, 0) != 0 && Util.compare(characterSpacing, -0.0f) != 0) {
new PdfNumber(characterSpacing).ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
canvas.InternalBuffer.Append(Tc);
}
if (Util.compare(wordSpacing, 0) != 0 && Util.compare(wordSpacing, -0.0f) != 0) {
new PdfNumber(wordSpacing).ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
canvas.InternalBuffer.Append(Tw);
}
}