本文整理匯總了C#中iTextSharp.text.pdf.PdfContentByte.MoveText方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentByte.MoveText方法的具體用法?C# PdfContentByte.MoveText怎麽用?C# PdfContentByte.MoveText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.MoveText方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 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 {
//.........這裏部分代碼省略.........
示例2: InitPage
/**
* Initializes a page.
* <P>
* If the footer/header is set, it is printed.
* @throws DocumentException on error
*/
protected internal void InitPage() {
// the pagenumber is incremented
pageN++;
// initialisation of some page objects
annotationsImp.ResetAnnotations();
pageResources = new PageResources();
writer.ResetContent();
graphics = new PdfContentByte(writer);
text = new PdfContentByte(writer);
text.Reset();
text.BeginText();
textEmptySize = text.Size;
markPoint = 0;
SetNewPageSizeAndMargins();
imageEnd = -1;
indentation.imageIndentRight = 0;
indentation.imageIndentLeft = 0;
indentation.indentBottom = 0;
indentation.indentTop = 0;
currentHeight = 0;
// backgroundcolors, etc...
thisBoxSize = new Hashtable(boxSize);
if (pageSize.BackgroundColor != null
|| pageSize.HasBorders()
|| pageSize.BorderColor != null) {
Add(pageSize);
}
float oldleading = leading;
int oldAlignment = alignment;
// we move to the left/top position of the page
text.MoveText(Left, Top);
pageEmpty = true;
// if there is an image waiting to be drawn, draw it
if (imageWait != null) {
Add(imageWait);
imageWait = null;
}
leading = oldleading;
alignment = oldAlignment;
CarriageReturn();
IPdfPageEvent pageEvent = writer.PageEvent;
if (pageEvent != null) {
if (firstPageEvent) {
pageEvent.OnOpenDocument(writer, this);
}
pageEvent.OnStartPage(writer, this);
}
firstPageEvent = false;
}
示例3: SetNewPageSizeAndMargins
protected internal void SetNewPageSizeAndMargins() {
pageSize = nextPageSize;
if (marginMirroring && (PageNumber & 1) == 0) {
marginRight = nextMarginLeft;
marginLeft = nextMarginRight;
}
else {
marginLeft = nextMarginLeft;
marginRight = nextMarginRight;
}
if (marginMirroringTopBottom && (PageNumber & 1) == 0) {
marginTop = nextMarginBottom;
marginBottom = nextMarginTop;
}
else {
marginTop = nextMarginTop;
marginBottom = nextMarginBottom;
}
text = new PdfContentByte(writer);
text.Reset();
text.BeginText();
textEmptySize = text.Size;
// we move to the left/top position of the page
text.MoveText(Left, Top);
}
示例4: 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))
//.........這裏部分代碼省略.........