本文整理匯總了C#中iTextSharp.text.pdf.parser.TextRenderInfo.GetText方法的典型用法代碼示例。如果您正苦於以下問題:C# TextRenderInfo.GetText方法的具體用法?C# TextRenderInfo.GetText怎麽用?C# TextRenderInfo.GetText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.parser.TextRenderInfo
的用法示例。
在下文中一共展示了TextRenderInfo.GetText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RenderText
/// Captures text using a simplified algorithm for inserting hard returns and spaces
/// @param renderInfo render info
public virtual void RenderText(TextRenderInfo renderInfo)
{
_blocks.Add(new TextBlock
{
Text = renderInfo.GetText(),
TopLeft = renderInfo.GetBaseline().GetStartPoint(),
BottomRight = renderInfo.GetBaseline().GetEndPoint()
});
}
示例2: RenderText
/// <summary>
/// <see cref="IRenderListener.RenderText"/>
/// </summary>
public void RenderText(TextRenderInfo renderInfo)
{
output.WriteLine(" <");
Vector start = renderInfo.GetBaseline().GetStartPoint();
output.WriteLine(String.Format(" x: {0} y: {1} length: {2} \n Text: {3}",
start[Vector.I1], start[Vector.I2],
renderInfo.GetBaseline().GetLength(),
renderInfo.GetText()));
output.WriteLine(" >");
}
示例3: RenderText
public void RenderText(TextRenderInfo renderInfo)
{
bool hardReturn = false;
LineSegment segment = renderInfo.GetBaseline();
Vector start = segment.GetStartPoint();
Vector end = segment.GetEndPoint();
if (lastStart != null && lastEnd != null)
{
Vector x0 = start;
Vector x1 = lastStart;
Vector x2 = lastEnd;
// see http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
float dist = (x2.Subtract(x1)).Cross((x1.Subtract(x0))).LengthSquared / x2.Subtract(x1).LengthSquared;
float sameLineThreshold = 1f; // we should probably base this on the current font metrics, but 1 pt seems to be sufficient for the time being
if (dist > sameLineThreshold)
hardReturn = true;
// Note: Technically, we should check both the start and end positions, in case the angle of the text changed without any displacement
// but this sort of thing probably doesn't happen much in reality, so we'll leave it alone for now
}
if (hardReturn)
{
//System.out.Println("<< Hard Return >>");
result.Append('\n');
}
else if (lastStart != null && lastEnd != null)
{
if (result[result.Length - 1] != ' ' && renderInfo.GetText()[0] != ' ')
{ // we only insert a blank space if the trailing character of the previous string wasn't a space, and the leading character of the current string isn't a space
float spacing = lastEnd.Subtract(start).Length;
if (spacing > renderInfo.GetSingleSpaceWidth() / 2f)
{
result.Append('\t');
//System.out.Println("Inserting implied space before '" + renderInfo.GetText() + "'");
}
}
}
else
{
//System.out.Println("Displaying first string of content '" + text + "' :: x1 = " + x1);
}
//System.out.Println("[" + renderInfo.GetStartPoint() + "]->[" + renderInfo.GetEndPoint() + "] " + renderInfo.GetText());
result.Append(renderInfo.GetText());
lastStart = start;
lastEnd = end;
}
示例4: RenderText
//Automatically called for each chunk of text in the PDF
public override void RenderText(TextRenderInfo renderInfo)
{
base.RenderText(renderInfo);
//See if the current chunk contains the text
var startPosition = System.Globalization.CultureInfo.CurrentCulture.CompareInfo.IndexOf(
renderInfo.GetText(), this.TextToSearchFor, this.CompareOptions);
//If not found bail
if (startPosition < 0)
{
return;
}
if (renderInfo.PdfString.ToString() != this.TextToSearchFor)
{
return;
}
//Grab the individual characters
var chars =
renderInfo.GetCharacterRenderInfos().Skip(startPosition).Take(this.TextToSearchFor.Length).ToList();
//Grab the first and last character
var firstChar = chars.First();
var lastChar = chars.Last();
//Get the bounding box for the chunk of text
var bottomLeft = firstChar.GetDescentLine().GetStartPoint();
var topRight = lastChar.GetAscentLine().GetEndPoint();
//Create a rectangle from it
var rect = new iTextSharp.text.Rectangle(
bottomLeft[Vector.I1],
bottomLeft[Vector.I2],
topRight[Vector.I1],
topRight[Vector.I2]
);
//Add this to our main collection
this.MyPoints.Add(new RectAndText(rect, this.TextToSearchFor));
}
示例5: RenderText
public override void RenderText(TextRenderInfo renderInfo)
{
base.RenderText(renderInfo);
var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
var topRight = renderInfo.GetAscentLine().GetEndPoint();
var rect = new iTextSharp.text.Rectangle(
bottomLeft[Vector.I1],
bottomLeft[Vector.I2],
topRight[Vector.I1],
topRight[Vector.I2]
);
this.containers.Add(new TextContainer()
{
Container = rect,
Text = renderInfo.GetText()
});
}
示例6: RenderText
public void RenderText(TextRenderInfo renderInfo)
{
var curFont = renderInfo.GetFont().PostscriptFontName;
//Check if faux bold is used
if ((renderInfo.GetTextRenderMode() == (int) TextRenderMode.FillThenStrokeText))
curFont += "-Bold";
//This code assumes that if the baseline changes then we're on a newline
var curBaseline = renderInfo.GetBaseline().GetStartPoint();
var topRight = renderInfo.GetAscentLine().GetEndPoint();
var rect = new Rectangle(curBaseline[Vector.I1], curBaseline[Vector.I2], topRight[Vector.I1], topRight[Vector.I2]);
var curFontSize = rect.Height;
//See if something has changed, either the baseline, the font or the font size
if ((lastBaseLine == null) || (curBaseline[Vector.I2] != lastBaseLine[Vector.I2]) || (curFontSize != lastFontSize) ||
(curFont != lastFont))
{
//if we've put down at least one span tag close it
if ((lastBaseLine != null))
result.AppendLine("</span>");
//If the baseline has changed then insert a line break
if ((lastBaseLine != null) && curBaseline[Vector.I2] != lastBaseLine[Vector.I2])
result.AppendLine("<br />");
//Create an HTML tag with appropriate styles
result.AppendFormat("<span style=\"font-family:{0};font-size:{1}; position: relative; top: {2}; left: {3};\">",
curFont, curFontSize, 850 - rect.Top, rect.Left);
}
//Append the current text
result.Append(renderInfo.GetText());
//Set currently used properties
lastBaseLine = curBaseline;
lastFontSize = curFontSize;
lastFont = curFont;
}
示例7: RenderText
//Automatically called for each chunk of text in the PDF
public override void RenderText(TextRenderInfo renderInfo) {
base.RenderText(renderInfo);
//Get the bounding box for the chunk of text
var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
var topRight = renderInfo.GetAscentLine().GetEndPoint();
//Create a rectangle from it
var rect = new iTextSharp.text.Rectangle(
bottomLeft[Vector.I1],
bottomLeft[Vector.I2],
topRight[Vector.I1],
topRight[Vector.I2]
);
//Add this to our main collection
this.myPoints.Add(new RectAndText(rect, renderInfo.GetText()));
}
示例8: RenderText
public void RenderText(TextRenderInfo renderInfo) {
buffer.Append(renderInfo.GetText());
buffer.Append("\n");
}
示例9: RenderText
virtual public void RenderText(TextRenderInfo renderInfo) {
textChunks.Add(renderInfo.GetText());
}
示例10: RenderText
/// <summary>
///
/// </summary>
/// <param name="renderInfo"></param>
public override void RenderText(TextRenderInfo renderInfo)
{
iTextSharp.text.pdf.parser.LineSegment segment = renderInfo.GetBaseline();
TextChunkEx location = new TextChunkEx(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth(), renderInfo.GetAscentLine(), renderInfo.GetDescentLine());
m_locationResult.Add(location);
}
示例11: RenderText
/// <summary>
///
/// </summary>
/// <param name="renderInfo"></param>
public override void RenderText(TextRenderInfo renderInfo)
{
LineSegment segment = renderInfo.GetBaseline();
string x = renderInfo.GetText();
TextChunk location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth(), renderInfo.GetAscentLine(), renderInfo.GetDescentLine());
m_locationResult.Add(location);
}
示例12: RenderText
/**
* @see com.itextpdf.text.pdf.parser.RenderListener#renderText(
* com.itextpdf.text.pdf.parser.TextRenderInfo)
*/
public void RenderText(TextRenderInfo renderInfo) {
Text.Append("<");
Text.Append(renderInfo.GetText());
Text.Append(">");
}
示例13: RenderText
public void RenderText(TextRenderInfo renderInfo)
{
_builder.Append(renderInfo.GetText() + " ");
// New page detected at copywrite statement.
if (renderInfo.GetText().Equals("Reserved."))
{
pages.Add(_builder.ToString());
_builder.Clear();
}
}
示例14: RenderText
public void RenderText(TextRenderInfo renderInfo)
{
bool firstRender = results.Count == 0;
LineSegment segment = renderInfo.GetBaseline();
Vector start = segment.GetStartPoint();
Vector end = segment.GetEndPoint();
int currentLineKey = (int)start[1];
if (!firstRender)
{
Vector x0 = start;
Vector x1 = lastStart;
Vector x2 = lastEnd;
float dist = (x2.Subtract(x1)).Cross((x1.Subtract(x0))).LengthSquared / x2.Subtract(x1).LengthSquared;
float sameLineThreshold = 1f;
if (dist <= sameLineThreshold)
{
currentLineKey = (int)lastStart[1];
}
}
currentLineKey = currentLineKey * -1;
if (!results.ContainsKey(currentLineKey))
{
results.Add(currentLineKey, new StringBuilder());
}
if (!firstRender &&
results[currentLineKey].Length != 0 &&
!results[currentLineKey].ToString().EndsWith(" ") &&
renderInfo.GetText().Length > 0 &&
!renderInfo.GetText().StartsWith(" "))
{
float spacing = lastEnd.Subtract(start).Length;
if (spacing > renderInfo.GetSingleSpaceWidth() / 2f)
{
results[currentLineKey].Append(" ");
}
}
results[currentLineKey].Append(renderInfo.GetText());
lastStart = start;
lastEnd = end;
}
示例15: RenderText
public void RenderText(TextRenderInfo renderInfo)
{
output.Write("<");
output.Write(renderInfo.GetText());
output.Write(">");
}