本文整理匯總了C#中iTextSharp.text.pdf.parser.TextRenderInfo.GetBaseline方法的典型用法代碼示例。如果您正苦於以下問題:C# TextRenderInfo.GetBaseline方法的具體用法?C# TextRenderInfo.GetBaseline怎麽用?C# TextRenderInfo.GetBaseline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.parser.TextRenderInfo
的用法示例。
在下文中一共展示了TextRenderInfo.GetBaseline方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: GetColor
/// <summary>
/// Determines the color that will mark the text snippet based on the
/// position of the snippet (in case it's an artifact) or it's style
/// (font name and size).
/// </summary>
/// <param name="textRenderInfo">the TextRenderInfo object</param>
/// <param name="top">the Y position of the top margin</param>
/// <returns>a color that will be used to mark the text snippet</returns>
static BaseColor GetColor(TextRenderInfo textRenderInfo, float top)
{
if (textRenderInfo.GetBaseline().GetStartPoint()[1] > top)
return artifactColor;
TextStyle ts = new TextStyle(textRenderInfo);
return textStyles[ts];
}
示例4: AllowText
/**
* @see com.itextpdf.text.pdf.parser.RenderFilter#allowText(com.itextpdf.text.pdf.parser.TextRenderInfo)
*/
public override bool AllowText(TextRenderInfo renderInfo){
LineSegment segment = renderInfo.GetBaseline();
Vector startPoint = segment.GetStartPoint();
Vector endPoint = segment.GetEndPoint();
float x1 = startPoint[Vector.I1];
float y1 = startPoint[Vector.I2];
float x2 = endPoint[Vector.I1];
float y2 = endPoint[Vector.I2];
return filterRect.IntersectsLine(x1, y1, x2, y2);
}
示例5: 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;
}
示例6: TextItem
/// <summary>
/// Creates a TextItem based on a TextRenderInfo object.
/// </summary>
/// <param name="textRenderInfo">the TextRenderInfo object</param>
/// <param name="top">the Y coordinate of the top margin</param>
public TextItem(TextRenderInfo textRenderInfo, float top)
{
textStyles.Add(new TextStyle("FranklinGothic", 10.5f), BaseColor.ORANGE);
textStyles.Add(new TextStyle("FranklinGothic", 8f), BaseColor.GREEN);
textStyles.Add(new TextStyle("NewBaskerville", 10f), BaseColor.BLUE);
textStyles.Add(new TextStyle("Courier", 9.5f), BaseColor.BLUE);
textStyles.Add(new TextStyle("CombiNumerals", 13.5f), BaseColor.PINK);
baseline = textRenderInfo.GetBaseline().GetStartPoint()[1];
rectangle = GetRectangle(textRenderInfo);
color = GetColor(textRenderInfo, top);
}
示例7: 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;
}
示例8: TextItemSimple
/// <summary>
/// Creates a TextItem based on a TextRenderInfo object.
/// </summary>
/// <param name="textRenderInfo">the TextRenderInfo object</param>
public TextItemSimple(TextRenderInfo textRenderInfo)
{
baseline = textRenderInfo.GetBaseline().GetStartPoint()[1];
rectangle = GetRectangle(textRenderInfo);
color = BaseColor.BLUE;
}
示例9: 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);
}
示例10: 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);
}
示例11: RenderText
virtual public void RenderText(TextRenderInfo renderInfo)
{
Vector start = renderInfo.GetBaseline().GetStartPoint();
float x = start[Vector.I1];
float y = start[Vector.I2];
// System.out.println("Display text: '" + renderInfo.getText() + "' (" + x + "," + y + ")");
if (y > _lastY)
{
Assert.Fail("Text has jumped back up the page");
}
_lastY = y;
}
示例12: RenderText
public void RenderText(TextRenderInfo renderInfo) {
lineSegments.Add(renderInfo.GetBaseline());
}
示例13: 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;
}