Porting update.
git-svn-id: svn://svn.code.sf.net/p/itextsharp/code/trunk@41 820d3149-562b-4f88-9aa4-a8e61a3485cfmaster
parent
5768f18023
commit
4878edd8cc
|
@ -109,7 +109,7 @@ namespace iTextSharp.text {
|
|||
* This constant may only be changed by Paulo Soares and/or Bruno Lowagie.
|
||||
* @since 2.1.6
|
||||
*/
|
||||
private const String RELEASE = "2.1.6_SNAPSHOT";
|
||||
private const String RELEASE = "4.1.6_C#";
|
||||
/** This constant may only be changed by Paulo Soares and/or Bruno Lowagie. */
|
||||
private const String ITEXT_VERSION = ITEXT + " " + RELEASE + " by 1T3XT";
|
||||
|
||||
|
@ -478,7 +478,7 @@ namespace iTextSharp.text {
|
|||
/// </summary>
|
||||
/// <returns>true if successful, false otherwise</returns>
|
||||
public bool AddProducer() {
|
||||
return Add(new Meta(Element.PRODUCER, "iText# by lowagie.com"));
|
||||
return Add(new Meta(Element.PRODUCER, Version));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -200,7 +200,7 @@ namespace iTextSharp.text.pdf {
|
|||
|
||||
private void AddToLine(PdfChunk chunk) {
|
||||
if (chunk.ChangeLeading && chunk.IsImage()) {
|
||||
float f = chunk.Image.ScaledHeight + chunk.ImageOffsetY;
|
||||
float f = chunk.Image.ScaledHeight + chunk.ImageOffsetY + chunk.Image.BorderWidthTop;
|
||||
if (f > height) height = f;
|
||||
}
|
||||
line.Add(chunk);
|
||||
|
|
|
@ -768,5 +768,60 @@ namespace iTextSharp.text.pdf {
|
|||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the cell.
|
||||
* @return the height of the cell
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public float GetMaxHeight() {
|
||||
bool pivoted = (Rotation == 90 || Rotation == 270);
|
||||
Image img = this.Image;
|
||||
if (img != null) {
|
||||
img.ScalePercent(100);
|
||||
float refWidth = pivoted ? img.ScaledHeight : img.ScaledWidth;
|
||||
float scale = (Right - EffectivePaddingRight
|
||||
- EffectivePaddingLeft - Left) / refWidth;
|
||||
img.ScalePercent(scale * 100);
|
||||
float refHeight = pivoted ? img.ScaledWidth : img.ScaledHeight;
|
||||
Bottom = Top - EffectivePaddingTop - EffectivePaddingBottom - refHeight;
|
||||
}
|
||||
else {
|
||||
if (pivoted && HasFixedHeight())
|
||||
Bottom = Top - FixedHeight;
|
||||
else {
|
||||
ColumnText ct = ColumnText.Duplicate(Column);
|
||||
float right, top, left, bottom;
|
||||
if (pivoted) {
|
||||
right = PdfPRow.RIGHT_LIMIT;
|
||||
top = Right - EffectivePaddingRight;
|
||||
left = 0;
|
||||
bottom = Left + EffectivePaddingLeft;
|
||||
}
|
||||
else {
|
||||
right = NoWrap ? PdfPRow.RIGHT_LIMIT : Right - EffectivePaddingRight;
|
||||
top = Top - EffectivePaddingTop;
|
||||
left = Left + EffectivePaddingLeft;
|
||||
bottom = HasFixedHeight() ? top + EffectivePaddingBottom - FixedHeight : PdfPRow.BOTTOM_LIMIT;
|
||||
}
|
||||
PdfPRow.SetColumn(ct, left, bottom, right, top);
|
||||
ct.Go(true);
|
||||
if (pivoted)
|
||||
Bottom = Top - EffectivePaddingTop - EffectivePaddingBottom - ct.FilledWidth;
|
||||
else {
|
||||
float yLine = ct.YLine;
|
||||
if (UseDescender)
|
||||
yLine += ct.Descender;
|
||||
Bottom = yLine - EffectivePaddingBottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
float height = Height;
|
||||
if (height < FixedHeight)
|
||||
height = FixedHeight;
|
||||
else if (height < MinimumHeight)
|
||||
height = MinimumHeight;
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -167,9 +167,9 @@ namespace iTextSharp.text.pdf {
|
|||
algorithmNames["1.2.840.10040.4.3"] = "DSA";
|
||||
algorithmNames["2.16.840.1.101.3.4.3.1"] = "DSA";
|
||||
algorithmNames["2.16.840.1.101.3.4.3.2"] = "DSA";
|
||||
digestNames["1.3.36.3.3.1.3"] = "RSA";
|
||||
digestNames["1.3.36.3.3.1.2"] = "RSA";
|
||||
digestNames["1.3.36.3.3.1.4"] = "RSA";
|
||||
algorithmNames["1.3.36.3.3.1.3"] = "RSA";
|
||||
algorithmNames["1.3.36.3.3.1.2"] = "RSA";
|
||||
algorithmNames["1.3.36.3.3.1.4"] = "RSA";
|
||||
|
||||
allowedDigests["MD5"] = "1.2.840.113549.2.5";
|
||||
allowedDigests["MD2"] = "1.2.840.113549.2.2";
|
||||
|
@ -416,19 +416,8 @@ namespace iTextSharp.text.pdf {
|
|||
next = 3;
|
||||
if (signerInfo[next] is Asn1TaggedObject) {
|
||||
Asn1TaggedObject tagsig = (Asn1TaggedObject)signerInfo[next];
|
||||
Asn1Sequence sseq = (Asn1Sequence)tagsig.GetObject();
|
||||
MemoryStream bOut = new MemoryStream();
|
||||
Asn1OutputStream dout = new Asn1OutputStream(bOut);
|
||||
try {
|
||||
Asn1EncodableVector attribute = new Asn1EncodableVector();
|
||||
for (int k = 0; k < sseq.Count; ++k) {
|
||||
attribute.Add(sseq[k]);
|
||||
}
|
||||
dout.WriteObject(new DerSet(attribute));
|
||||
dout.Close();
|
||||
}
|
||||
catch (IOException){}
|
||||
sigAttr = bOut.ToArray();
|
||||
Asn1Set sseq = Asn1Set.GetInstance(tagsig, false);
|
||||
sigAttr = sseq.GetEncoded(Asn1Encodable.Der);
|
||||
|
||||
for (int k = 0; k < sseq.Count; ++k) {
|
||||
Asn1Sequence seq2 = (Asn1Sequence)sseq[k];
|
||||
|
@ -456,16 +445,14 @@ namespace iTextSharp.text.pdf {
|
|||
digest = ((DerOctetString)signerInfo[next++]).GetOctets();
|
||||
if (next < signerInfo.Count && (signerInfo[next] is DerTaggedObject)) {
|
||||
DerTaggedObject taggedObject = (DerTaggedObject) signerInfo[next];
|
||||
Asn1Object obje = taggedObject.GetObject();
|
||||
if (obje is DerSequence) {
|
||||
DerSequence sequence = (DerSequence) obje;
|
||||
DerObjectIdentifier oid = (DerObjectIdentifier)sequence[0];
|
||||
if (PkcsObjectIdentifiers.IdAASignatureTimeStampToken.Id.Equals(oid.Id)) {
|
||||
Asn1Set attributeValues = Asn1Set.GetInstance(sequence[1]);
|
||||
Asn1Sequence tokenSequence = Asn1Sequence.GetInstance(attributeValues[0]);
|
||||
Org.BouncyCastle.Asn1.Cms.ContentInfo contentInfo = Org.BouncyCastle.Asn1.Cms.ContentInfo.GetInstance(tokenSequence);
|
||||
this.timeStampToken = new TimeStampToken(contentInfo);
|
||||
}
|
||||
Asn1Set unat = Asn1Set.GetInstance(taggedObject, false);
|
||||
Org.BouncyCastle.Asn1.Cms.AttributeTable attble = new Org.BouncyCastle.Asn1.Cms.AttributeTable(unat);
|
||||
Org.BouncyCastle.Asn1.Cms.Attribute ts = attble[PkcsObjectIdentifiers.IdAASignatureTimeStampToken];
|
||||
if (ts != null) {
|
||||
Asn1Set attributeValues = ts.AttrValues;
|
||||
Asn1Sequence tokenSequence = Asn1Sequence.GetInstance(attributeValues[0]);
|
||||
Org.BouncyCastle.Asn1.Cms.ContentInfo contentInfo = Org.BouncyCastle.Asn1.Cms.ContentInfo.GetInstance(tokenSequence);
|
||||
this.timeStampToken = new TimeStampToken(contentInfo);
|
||||
}
|
||||
}
|
||||
if (RSAdata != null || digestAttr != null) {
|
||||
|
@ -1243,13 +1230,7 @@ namespace iTextSharp.text.pdf {
|
|||
* @return the byte array representation of the authenticatedAttributes ready to be signed
|
||||
*/
|
||||
public byte[] GetAuthenticatedAttributeBytes(byte[] secondDigest, DateTime signingTime, byte[] ocsp) {
|
||||
MemoryStream bOut = new MemoryStream();
|
||||
|
||||
Asn1OutputStream dout = new Asn1OutputStream(bOut);
|
||||
dout.WriteObject(GetAuthenticatedAttributeSet(secondDigest, signingTime, ocsp));
|
||||
dout.Close();
|
||||
|
||||
return bOut.ToArray();
|
||||
return GetAuthenticatedAttributeSet(secondDigest, signingTime, ocsp).GetEncoded(Asn1Encodable.Der);
|
||||
}
|
||||
|
||||
private DerSet GetAuthenticatedAttributeSet(byte[] secondDigest, DateTime signingTime, byte[] ocsp) {
|
||||
|
|
|
@ -180,55 +180,7 @@ namespace iTextSharp.text.pdf {
|
|||
continue;
|
||||
}
|
||||
else {
|
||||
bool pivoted = (cell.Rotation == 90 || cell.Rotation == 270);
|
||||
Image img = cell.Image;
|
||||
if (img != null) {
|
||||
img.ScalePercent(100);
|
||||
float refWidth = pivoted ? img.ScaledHeight : img.ScaledWidth;
|
||||
float scale = (cell.Right - cell.EffectivePaddingRight
|
||||
- cell.EffectivePaddingLeft - cell.Left) / refWidth;
|
||||
img.ScalePercent(scale * 100);
|
||||
float refHeight = pivoted ? img.ScaledWidth : img.ScaledHeight;
|
||||
cell.Bottom = cell.Top - cell.EffectivePaddingTop
|
||||
- cell.EffectivePaddingBottom - refHeight;
|
||||
}
|
||||
else {
|
||||
if (pivoted && cell.HasFixedHeight())
|
||||
cell.Bottom = cell.Top - cell.FixedHeight;
|
||||
else {
|
||||
ColumnText ct = ColumnText.Duplicate(cell.Column);
|
||||
float right, top, left, bottom;
|
||||
if (pivoted) {
|
||||
right = RIGHT_LIMIT;
|
||||
top = cell.Right - cell.EffectivePaddingRight;
|
||||
left = 0;
|
||||
bottom = cell.Left + cell.EffectivePaddingLeft;
|
||||
}
|
||||
else {
|
||||
right = cell.NoWrap ? RIGHT_LIMIT : cell.Right - cell.EffectivePaddingRight;
|
||||
top = cell.Top - cell.EffectivePaddingTop;
|
||||
left = cell.Left + cell.EffectivePaddingLeft;
|
||||
bottom = cell.HasFixedHeight() ? top + cell.EffectivePaddingBottom - cell.FixedHeight : BOTTOM_LIMIT;
|
||||
}
|
||||
SetColumn(ct, left, bottom, right, top);
|
||||
ct.Go(true);
|
||||
if (pivoted)
|
||||
cell.Bottom = cell.Top - cell.EffectivePaddingTop - cell.EffectivePaddingBottom - ct.FilledWidth;
|
||||
else {
|
||||
float yLine = ct.YLine;
|
||||
if (cell.UseDescender)
|
||||
yLine += ct.Descender;
|
||||
cell.Bottom = yLine - cell.EffectivePaddingBottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
height = cell.FixedHeight;
|
||||
if (height <= 0)
|
||||
height = cell.Height;
|
||||
if (height < cell.FixedHeight)
|
||||
height = cell.FixedHeight;
|
||||
else if (height < cell.MinimumHeight)
|
||||
height = cell.MinimumHeight;
|
||||
height = cell.GetMaxHeight();
|
||||
if ((height > maxHeight) && (cell.Rowspan == 1))
|
||||
maxHeight = height;
|
||||
}
|
||||
|
@ -305,9 +257,9 @@ namespace iTextSharp.text.pdf {
|
|||
}
|
||||
|
||||
/**
|
||||
* @since 2.1.6 private is now protected
|
||||
* @since 3.0.0 protected is now public static
|
||||
*/
|
||||
protected internal float SetColumn(ColumnText ct, float left, float bottom, float right, float top) {
|
||||
public static float SetColumn(ColumnText ct, float left, float bottom, float right, float top) {
|
||||
if (left > right)
|
||||
right = left;
|
||||
if (bottom > top)
|
||||
|
|
|
@ -358,12 +358,7 @@ namespace iTextSharp.text.pdf {
|
|||
return 0;
|
||||
totalHeight = 0;
|
||||
for (int k = 0; k < rows.Count; ++k) {
|
||||
PdfPRow row = (PdfPRow)rows[k];
|
||||
if (row != null) {
|
||||
if (firsttime)
|
||||
row.SetWidths(absoluteWidths);
|
||||
totalHeight += row.MaxHeights;
|
||||
}
|
||||
totalHeight += GetRowHeight(k, firsttime);
|
||||
}
|
||||
return totalHeight;
|
||||
}
|
||||
|
@ -761,12 +756,49 @@ namespace iTextSharp.text.pdf {
|
|||
* @return the height of a particular row
|
||||
*/
|
||||
public float GetRowHeight(int idx) {
|
||||
return GetRowHeight(idx, false);
|
||||
}
|
||||
/**
|
||||
* Gets the height of a particular row.
|
||||
*
|
||||
* @param idx the row index (starts at 0)
|
||||
* @param firsttime is this the first time the row heigh is calculated?
|
||||
* @return the height of a particular row
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public float GetRowHeight(int idx, bool firsttime) {
|
||||
if (totalWidth <= 0 || idx < 0 || idx >= rows.Count)
|
||||
return 0;
|
||||
PdfPRow row = (PdfPRow)rows[idx];
|
||||
if (row == null)
|
||||
return 0;
|
||||
return row.MaxHeights;
|
||||
if (firsttime)
|
||||
row.SetWidths(absoluteWidths);
|
||||
float height = row.MaxHeights;
|
||||
PdfPCell cell;
|
||||
PdfPRow tmprow;
|
||||
for (int i = 0; i < relativeWidths.Length; i++) {
|
||||
if(!RowSpanAbove(idx, i))
|
||||
continue;
|
||||
int rs = 1;
|
||||
while (RowSpanAbove(idx - rs, i)) {
|
||||
rs++;
|
||||
}
|
||||
tmprow = (PdfPRow)rows[idx - rs];
|
||||
cell = tmprow.GetCells()[i];
|
||||
float tmp = 0;
|
||||
if (cell.Rowspan == rs + 1) {
|
||||
tmp = cell.GetMaxHeight();
|
||||
while (rs > 0) {
|
||||
tmp -= GetRowHeight(idx - rs);
|
||||
rs--;
|
||||
}
|
||||
}
|
||||
if (tmp > height)
|
||||
height = tmp;
|
||||
}
|
||||
row.MaxHeights = height;
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace iTextSharp.text.pdf {
|
|||
String producer = null;
|
||||
if (iInfo != null)
|
||||
skipInfo = iInfo.Number;
|
||||
if (oldInfo != null)
|
||||
if (oldInfo != null && oldInfo.Get(PdfName.PRODUCER) != null)
|
||||
producer = oldInfo.GetAsString(PdfName.PRODUCER).ToString();
|
||||
if (producer == null) {
|
||||
producer = Document.Version;
|
||||
|
|
Loading…
Reference in New Issue