本文整理匯總了C#中iTextSharp.text.pdf.PdfPRow.CalculateHeights方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfPRow.CalculateHeights方法的具體用法?C# PdfPRow.CalculateHeights怎麽用?C# PdfPRow.CalculateHeights使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfPRow
的用法示例。
在下文中一共展示了PdfPRow.CalculateHeights方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SplitRow
/**
* Splits a row to newHeight.
* The returned row is the remainder. It will return null if the newHeight
* was so small that only an empty row would result.
*
* @param new_height the new height
* @return the remainder row or null if the newHeight was so small that only
* an empty row would result
*/
public PdfPRow SplitRow(PdfPTable table, int rowIndex, float new_height) {
PdfPCell[] newCells = new PdfPCell[cells.Length];
float[] fixHs = new float[cells.Length];
float[] minHs = new float[cells.Length];
bool allEmpty = true;
for (int k = 0; k < cells.Length; ++k) {
float newHeight = new_height;
PdfPCell cell = cells[k];
if (cell == null) {
int index = rowIndex;
if (table.RowSpanAbove(index, k)) {
newHeight += table.GetRowHeight(index);
while (table.RowSpanAbove(--index, k)) {
newHeight += table.GetRowHeight(index);
}
PdfPRow row = table.GetRow(index);
if (row != null && row.GetCells()[k] != null) {
newCells[k] = new PdfPCell(row.GetCells()[k]);
newCells[k].ConsumeHeight(newHeight);
newCells[k].Rowspan = row.GetCells()[k].Rowspan - rowIndex + index;
allEmpty = false;
}
}
continue;
}
fixHs[k] = cell.FixedHeight;
minHs[k] = cell.MinimumHeight;
Image img = cell.Image;
PdfPCell newCell = new PdfPCell(cell);
if (img != null) {
if (newHeight > cell.EffectivePaddingBottom + cell.EffectivePaddingTop + 2) {
newCell.Phrase = null;
allEmpty = false;
}
}
else {
float y;
ColumnText ct = ColumnText.Duplicate(cell.Column);
float left = cell.Left + cell.EffectivePaddingLeft;
float bottom = cell.Top + cell.EffectivePaddingBottom - newHeight;
float right = cell.Right - cell.EffectivePaddingRight;
float top = cell.Top - cell.EffectivePaddingTop;
switch (cell.Rotation) {
case 90:
case 270:
y = SetColumn(ct, bottom, left, top, right);
break;
default:
y = SetColumn(ct, left, bottom + 0.00001f, cell.NoWrap ? RIGHT_LIMIT : right, top);
break;
}
int status;
status = ct.Go(true);
bool thisEmpty = (ct.YLine == y);
if (thisEmpty) {
newCell.Column = ColumnText.Duplicate(cell.Column);
ct.FilledWidth = 0;
}
else if ((status & ColumnText.NO_MORE_TEXT) == 0) {
newCell.Column = ct;
ct.FilledWidth = 0;
}
else
newCell.Phrase = null;
allEmpty = (allEmpty && thisEmpty);
}
newCells[k] = newCell;
cell.FixedHeight = newHeight;
}
if (allEmpty) {
for (int k = 0; k < cells.Length; ++k) {
PdfPCell cell = cells[k];
if (cell == null)
continue;
if (fixHs[k] > 0)
cell.FixedHeight = fixHs[k];
else
cell.MinimumHeight = minHs[k];
}
return null;
}
CalculateHeights();
PdfPRow split = new PdfPRow(newCells);
split.widths = (float[]) widths.Clone();
split.CalculateHeights();
return split;
}
示例2: SplitRow
/**
* Splits a row to newHeight. The returned row is the remainder. It will
* return null if the newHeight was so small that only an empty row would
* result.
*
* @param newHeight
* the new height
* @return the remainder row or null if the newHeight was so small that only
* an empty row would result
*/
public PdfPRow SplitRow(float newHeight)
{
PdfPCell[] newCells = new PdfPCell[cells.Length];
float[] fh = new float[cells.Length * 2];
bool allEmpty = true;
for (int k = 0; k < cells.Length; ++k) {
PdfPCell cell = cells[k];
if (cell == null)
continue;
fh[k * 2] = cell.FixedHeight;
fh[k * 2 + 1] = cell.MinimumHeight;
Image img = cell.Image;
PdfPCell c2 = new PdfPCell(cell);
if (img != null) {
if (newHeight > cell.EffectivePaddingBottom
+ cell.EffectivePaddingTop + 2) {
c2.Phrase = null;
allEmpty = false;
}
} else {
int status;
float y;
ColumnText ct = ColumnText.Duplicate(cell.Column);
if (cell.Rotation == 90 || cell.Rotation == 270) {
y = SetColumn(ct,
cell.Top - newHeight + cell.EffectivePaddingBottom,
cell.Left + cell.EffectivePaddingLeft,
cell.Top - cell.EffectivePaddingTop,
cell.Right - cell.EffectivePaddingRight);
}
else {
float rightLimit = cell.NoWrap ? 20000 : cell.Right
- cell.EffectivePaddingRight;
float y1 = cell.Top - newHeight
+ cell.EffectivePaddingBottom;
float y2 = cell.Top - cell.EffectivePaddingTop;
y = Math.Max(y1, y2);
y = SetColumn(ct,
cell.Left + cell.EffectivePaddingLeft, y1,
rightLimit, y2);
}
status = ct.Go(true);
bool thisEmpty = (ct.YLine == y);
if (thisEmpty)
ct = ColumnText.Duplicate(cell.Column);
allEmpty = (allEmpty && thisEmpty);
if ((status & ColumnText.NO_MORE_TEXT) == 0 || thisEmpty) {
c2.Column = ct;
ct.FilledWidth = 0;
} else {
c2.Phrase = null;
}
}
newCells[k] = c2;
cell.FixedHeight = newHeight;
}
if (allEmpty) {
for (int k = 0; k < cells.Length; ++k) {
PdfPCell cell = cells[k];
if (cell == null)
continue;
float f = fh[k * 2];
float m = fh[k * 2 + 1];
if (f <= 0)
cell.MinimumHeight = m;
else
cell.FixedHeight = f;
}
return null;
}
CalculateHeights();
PdfPRow split = new PdfPRow(newCells);
split.widths = (float[]) widths.Clone();
split.CalculateHeights();
return split;
}