本文整理匯總了C#中iTextSharp.text.pdf.PdfLine.GetChunk方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfLine.GetChunk方法的具體用法?C# PdfLine.GetChunk怎麽用?C# PdfLine.GetChunk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfLine
的用法示例。
在下文中一共展示了PdfLine.GetChunk方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PdfCell
//.........這裏部分代碼省略.........
}
line.ResetAlignment();
AddLine(line);
line = new PdfLine(left + item.IndentationLeft, right, alignment, leading);
}
}
line = new PdfLine(left, right, alignment, leading);
break;
// if the element is something else
default:
allActions = new ArrayList();
ProcessActions(ele, null, allActions);
aCounter = 0;
float currentLineLeading = leading;
float currentLeft = left;
float currentRight = right;
if (ele is Phrase) {
currentLineLeading = ((Phrase) ele).Leading;
}
if (ele is Paragraph) {
Paragraph p = (Paragraph) ele;
currentLeft += p.IndentationLeft;
currentRight -= p.IndentationRight;
}
if (line == null) {
line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
}
// we loop over the chunks
ArrayList chunks = ele.Chunks;
if (chunks.Count == 0) {
AddLine(line); // add empty line - all cells need some lines even if they are empty
line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
}
else {
foreach (Chunk c in chunks) {
chunk = new PdfChunk(c, (PdfAction)allActions[aCounter++]);
while ((overflow = line.Add(chunk)) != null) {
AddLine(line);
line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
chunk = overflow;
}
}
}
// if the element is a paragraph, section or chapter, we reset the alignment and add the line
switch (ele.Type) {
case Element.PARAGRAPH:
case Element.SECTION:
case Element.CHAPTER:
line.ResetAlignment();
FlushCurrentLine();
break;
}
break;
}
}
FlushCurrentLine();
if (lines.Count > cell.MaxLines) {
while (lines.Count > cell.MaxLines) {
RemoveLine(lines.Count - 1);
}
if (cell.MaxLines > 0) {
String more = cell.ShowTruncation;
if (more != null && more.Length > 0) {
// Denote that the content has been truncated
lastLine = (PdfLine) lines[lines.Count - 1];
if (lastLine.Size >= 0) {
PdfChunk lastChunk = lastLine.GetChunk(lastLine.Size - 1);
float moreWidth = new PdfChunk(more, lastChunk).Width;
while (lastChunk.ToString().Length > 0 && lastChunk.Width + moreWidth > right - left) {
// Remove characters to leave room for the 'more' indicator
lastChunk.Value = lastChunk.ToString().Substring(0, lastChunk.Length - 1);
}
lastChunk.Value = lastChunk.ToString() + more;
} else {
lastLine.Add(new PdfChunk(new Chunk(more), null));
}
}
}
}
// we set some additional parameters
if (useDescender && lastLine != null) {
contentHeight -= lastLine.Descender;
}
// adjust first line height so that it touches the top
if (lines.Count > 0) {
firstLine = (PdfLine) lines[0];
float firstLineRealHeight = FirstLineRealHeight;
contentHeight -= firstLine.Height;
firstLine.height = firstLineRealHeight;
contentHeight += firstLineRealHeight;
}
float newBottom = top - contentHeight - (2f * Cellpadding) - (2f * Cellspacing);
newBottom -= GetBorderWidthInside(TOP_BORDER) + GetBorderWidthInside(BOTTOM_BORDER);
Bottom = newBottom;
this.rownumber = rownumber;
}
示例2: WriteLineToContent
/**
* Writes a text line to the document. It takes care of all the attributes.
* <P>
* Before entering the line position must have been established and the
* <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>).
* @param line the line to be written
* @param text the <CODE>PdfContentByte</CODE> where the text will be written to
* @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to
* @param currentValues the current font and extra spacing values
* @param ratio
* @throws DocumentException on error
*/
internal float WriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio) {
PdfFont currentFont = (PdfFont)(currentValues[0]);
float lastBaseFactor = (float)currentValues[1];
//PdfChunk chunkz;
int numberOfSpaces;
int lineLen;
bool isJustified;
float hangingCorrection = 0;
float hScale = 1;
float lastHScale = float.NaN;
float baseWordSpacing = 0;
float baseCharacterSpacing = 0;
float glueWidth = 0;
float lastX = text.XTLM + line.OriginalWidth;
numberOfSpaces = line.NumberOfSpaces;
lineLen = line.GetLineLengthUtf32();
// does the line need to be justified?
isJustified = line.HasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1);
int separatorCount = line.GetSeparatorCount();
if (separatorCount > 0) {
glueWidth = line.WidthLeft / separatorCount;
}
else if (isJustified && separatorCount == 0) {
if (line.NewlineSplit && line.WidthLeft >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) {
if (line.RTL) {
text.MoveText(line.WidthLeft - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0);
}
baseWordSpacing = ratio * lastBaseFactor;
baseCharacterSpacing = lastBaseFactor;
}
else {
float width = line.WidthLeft;
PdfChunk last = line.GetChunk(line.Size - 1);
if (last != null) {
String s = last.ToString();
char c;
if (s.Length > 0 && hangingPunctuation.IndexOf((c = s[s.Length - 1])) >= 0) {
float oldWidth = width;
width += last.Font.Width(c) * 0.4f;
hangingCorrection = width - oldWidth;
}
}
float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1);
baseWordSpacing = ratio * baseFactor;
baseCharacterSpacing = baseFactor;
lastBaseFactor = baseFactor;
}
}
else if (line.alignment == Element.ALIGN_LEFT || line.alignment == Element.ALIGN_UNDEFINED) {
lastX -= line.WidthLeft;
}
int lastChunkStroke = line.LastStrokeChunk;
int chunkStrokeIdx = 0;
float xMarker = text.XTLM;
float baseXMarker = xMarker;
float yMarker = text.YTLM;
bool adjustMatrix = false;
float tabPosition = 0;
// looping over all the chunks in 1 line
foreach (PdfChunk chunk in line) {
if (IsTagged(writer) && chunk.accessibleElement != null) {
text.OpenMCBlock(chunk.accessibleElement);
}
BaseColor color = chunk.Color;
float fontSize = chunk.Font.Size;
float ascender;
float descender;
if (chunk.IsImage())
{
ascender = chunk.Height();
descender = 0;
}
else
{
ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
}
hScale = 1;
if (chunkStrokeIdx <= lastChunkStroke) {
float width;
if (isJustified) {
width = chunk.GetWidthCorrected(baseCharacterSpacing, baseWordSpacing);
}
else {
//.........這裏部分代碼省略.........
示例3: WriteLineToContent
/**
* Writes a text line to the document. It takes care of all the attributes.
* <P>
* Before entering the line position must have been established and the
* <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>).
* @param line the line to be written
* @param text the <CODE>PdfContentByte</CODE> where the text will be written to
* @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to
* @param currentValues the current font and extra spacing values
* @param ratio
* @throws DocumentException on error
*/
internal void WriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio)
{
PdfFont currentFont = (PdfFont)(currentValues[0]);
float lastBaseFactor = (float)currentValues[1];
//PdfChunk chunkz;
int numberOfSpaces;
int lineLen;
bool isJustified;
float hangingCorrection = 0;
float hScale = 1;
float lastHScale = float.NaN;
float baseWordSpacing = 0;
float baseCharacterSpacing = 0;
numberOfSpaces = line.NumberOfSpaces;
lineLen = line.ToString().Length;
// does the line need to be justified?
isJustified = line.HasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1);
if (isJustified) {
if (line.NewlineSplit && line.WidthLeft >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) {
if (line.RTL) {
text.MoveText(line.WidthLeft - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0);
}
baseWordSpacing = ratio * lastBaseFactor;
baseCharacterSpacing = lastBaseFactor;
}
else {
float width = line.WidthLeft;
PdfChunk last = line.GetChunk(line.Size - 1);
if (last != null) {
String s = last.ToString();
char c;
if (s.Length > 0 && hangingPunctuation.IndexOf((c = s[s.Length - 1])) >= 0) {
float oldWidth = width;
width += last.Font.Width(c) * 0.4f;
hangingCorrection = width - oldWidth;
}
}
float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1);
baseWordSpacing = ratio * baseFactor;
baseCharacterSpacing = baseFactor;
lastBaseFactor = baseFactor;
}
}
int lastChunkStroke = line.LastStrokeChunk;
int chunkStrokeIdx = 0;
float xMarker = text.XTLM;
float baseXMarker = xMarker;
float yMarker = text.YTLM;
bool adjustMatrix = false;
// looping over all the chunks in 1 line
foreach (PdfChunk chunk in line) {
Color color = chunk.Color;
hScale = 1;
if (chunkStrokeIdx <= lastChunkStroke) {
float width;
if (isJustified) {
width = chunk.GetWidthCorrected(baseCharacterSpacing, baseWordSpacing);
}
else
width = chunk.Width;
if (chunk.IsStroked()) {
PdfChunk nextChunk = line.GetChunk(chunkStrokeIdx + 1);
if (chunk.IsAttribute(Chunk.BACKGROUND)) {
float subtract = lastBaseFactor;
if (nextChunk != null && nextChunk.IsAttribute(Chunk.BACKGROUND))
subtract = 0;
if (nextChunk == null)
subtract += hangingCorrection;
float fontSize = chunk.Font.Size;
float ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
float descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
Object[] bgr = (Object[])chunk.GetAttribute(Chunk.BACKGROUND);
graphics.SetColorFill((Color)bgr[0]);
float[] extra = (float[])bgr[1];
graphics.Rectangle(xMarker - extra[0],
yMarker + descender - extra[1] + chunk.TextRise,
width - subtract + extra[0] + extra[2],
ascender - descender + extra[1] + extra[3]);
graphics.Fill();
graphics.SetGrayFill(0);
}
if (chunk.IsAttribute(Chunk.UNDERLINE)) {
float subtract = lastBaseFactor;
if (nextChunk != null && nextChunk.IsAttribute(Chunk.UNDERLINE))
//.........這裏部分代碼省略.........