本文整理匯總了C#中iTextSharp.text.pdf.PdfLine.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfLine.ToString方法的具體用法?C# PdfLine.ToString怎麽用?C# PdfLine.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfLine
的用法示例。
在下文中一共展示了PdfLine.ToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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))
//.........這裏部分代碼省略.........