Porting update.

git-svn-id: svn://svn.code.sf.net/p/itextsharp/code/trunk@21 820d3149-562b-4f88-9aa4-a8e61a3485cf
master
psoares33 2009-06-03 22:43:40 +00:00
parent b972119de6
commit a8cf4120eb
7 changed files with 1059 additions and 396 deletions

View File

@ -263,18 +263,23 @@ namespace iTextSharp.text.pdf {
}
}
}
ThrowError("Unexpected end of file");
// if we hit here, the file is either corrupt (stream ended unexpectedly),
// or the last token ended exactly at the end of a stream. This last
// case can occur inside an Object Stream.
}
public bool NextToken() {
StringBuilder outBuf = null;
stringValue = EMPTY;
int ch = 0;
do {
ch = file.Read();
} while (ch != -1 && IsWhitespace(ch));
if (ch == -1)
return false;
// Note: We have to initialize stringValue here, after we've looked for the end of the stream,
// to ensure that we don't lose the value of a token that might end exactly at the end
// of the stream
StringBuilder outBuf = null;
stringValue = EMPTY;
switch (ch) {
case '[':
type = TK_START_ARRAY;

View File

@ -407,16 +407,16 @@ public class PdfEncryption {
else
stdcf.Put(PdfName.CFM, PdfName.V2);
PdfDictionary cf = new PdfDictionary();
cf.Put(PdfName.DEFAULTCRYPTFILER, stdcf);
cf.Put(PdfName.DEFAULTCRYPTFILTER, stdcf);
dic.Put(PdfName.CF, cf);
if (embeddedFilesOnly) {
dic.Put(PdfName.EFF, PdfName.DEFAULTCRYPTFILER);
dic.Put(PdfName.EFF, PdfName.DEFAULTCRYPTFILTER);
dic.Put(PdfName.STRF, PdfName.IDENTITY);
dic.Put(PdfName.STMF, PdfName.IDENTITY);
}
else {
dic.Put(PdfName.STRF, PdfName.DEFAULTCRYPTFILER);
dic.Put(PdfName.STMF, PdfName.DEFAULTCRYPTFILER);
dic.Put(PdfName.STRF, PdfName.DEFAULTCRYPTFILTER);
dic.Put(PdfName.STMF, PdfName.DEFAULTCRYPTFILTER);
}
}

View File

@ -263,9 +263,9 @@ namespace iTextSharp.text.pdf {
PdfDictionary usage = Usage;
PdfDictionary dic = new PdfDictionary();
if (min > 0)
dic.Put(PdfName.MIN, new PdfNumber(min));
dic.Put(PdfName.MIN_LOWER_CASE, new PdfNumber(min));
if (max >= 0)
dic.Put(PdfName.MAX, new PdfNumber(max));
dic.Put(PdfName.MAX_LOWER_CASE, new PdfNumber(max));
usage.Put(PdfName.ZOOM, dic);
}

File diff suppressed because it is too large Load Diff

View File

@ -657,7 +657,7 @@ namespace iTextSharp.text.pdf {
PdfDictionary dic = (PdfDictionary)enc.Get(PdfName.CF);
if (dic == null)
throw new IOException("/CF not found (encryption)");
dic = (PdfDictionary)dic.Get(PdfName.DEFAULTCRYPTFILER);
dic = (PdfDictionary)dic.Get(PdfName.DEFAULTCRYPTFILTER);
if (dic == null)
throw new IOException("/DefaultCryptFilter not found (encryption)");
if (PdfName.V2.Equals(dic.Get(PdfName.CFM)))

View File

@ -197,6 +197,10 @@ namespace iTextSharp.text.pdf {
public PdfIndirectReference IndirectReference {
get {
// uncomment the null check as soon as we're sure all examples still work
if (thisReference == null /* && writer != null */) {
thisReference = writer.PdfIndirectReference;
}
return thisReference;
}
}

View File

@ -143,7 +143,7 @@ namespace iTextSharp.text.pdf.codec {
private const int PNG_FILTER_AVERAGE = 3;
private const int PNG_FILTER_PAETH = 4;
private static PdfName[] intents = {PdfName.PERCEPTUAL,
PdfName.RELATIVECALORIMETRIC,PdfName.SATURATION,PdfName.ABSOLUTECALORIMETRIC};
PdfName.RELATIVECOLORIMETRIC,PdfName.SATURATION,PdfName.ABSOLUTECOLORIMETRIC};
Stream isp;
Stream dataStream;
@ -738,6 +738,8 @@ namespace iTextSharp.text.pdf.codec {
int idx = outp[srcX];
if (idx < trans.Length)
v[0] = trans[idx];
else
v[0] = 255; // Patrick Valsecchi
SetPixel(smask, v, 0, 1, dstX, y, 8, yStride);
dstX += step;
}
@ -751,8 +753,7 @@ namespace iTextSharp.text.pdf.codec {
dstX = xOffset;
for (srcX = 0; srcX < width; srcX++) {
int idx = outp[srcX];
if (idx < trans.Length)
v[0] = (trans[idx] == 0 ? 1 : 0);
v[0] = ((idx < trans.Length && trans[idx] == 0) ? 1 : 0);
SetPixel(smask, v, 0, 1, dstX, y, 1, yStride);
dstX += step;
}