本文整理汇总了C#中iTextSharp.text.pdf.IntHashtable类的典型用法代码示例。如果您正苦于以下问题:C# IntHashtable类的具体用法?C# IntHashtable怎么用?C# IntHashtable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntHashtable类属于iTextSharp.text.pdf命名空间,在下文中一共展示了IntHashtable类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyDocumentFields
/**
* This method feeds in the source document
* @param reader The PDF reader containing the source document
* @throws DocumentException
*/
public void CopyDocumentFields(PdfReader reader) {
if (!reader.IsOpenedWithFullPermissions)
throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));
if (readers2intrefs.ContainsKey(reader)) {
reader = new PdfReader(reader);
}
else {
if (reader.Tampered)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.document.was.reused"));
reader.ConsolidateNamedDestinations();
reader.Tampered = true;
}
reader.ShuffleSubsetNames();
readers2intrefs[reader] = new IntHashtable();
fields.Add(reader.AcroFields);
UpdateCalculationOrder(reader);
}
示例2: GetNamedDestination
public static Hashtable GetNamedDestination(PdfReader reader, bool fromNames) {
IntHashtable pages = new IntHashtable();
int numPages = reader.NumberOfPages;
for (int k = 1; k <= numPages; ++k)
pages[reader.GetPageOrigRef(k).Number] = k;
Hashtable names = fromNames ? reader.GetNamedDestinationFromNames() : reader.GetNamedDestinationFromStrings();
String[] keys = new String[names.Count];
names.Keys.CopyTo(keys, 0);
foreach (String name in keys) {
PdfArray arr = (PdfArray)names[name];
StringBuilder s = new StringBuilder();
try {
s.Append(pages[(arr.GetAsIndirectObject(0)).Number]);
s.Append(' ').Append(arr[1].ToString().Substring(1));
for (int k = 2; k < arr.Size; ++k)
s.Append(' ').Append(arr[k].ToString());
names[name] = s.ToString();
}
catch {
names.Remove(name);
}
}
return names;
}
示例3: FindAllObjects
internal static void FindAllObjects(PdfReader reader, PdfObject obj, IntHashtable hits) {
if (obj == null)
return;
switch (obj.Type) {
case PdfObject.INDIRECT:
PRIndirectReference iref = (PRIndirectReference)obj;
if (reader != iref.Reader)
return;
if (hits.ContainsKey(iref.Number))
return;
hits[iref.Number] = 1;
FindAllObjects(reader, PdfReader.GetPdfObject(obj), hits);
return;
case PdfObject.ARRAY:
PdfArray a = (PdfArray)obj;
for (int k = 0; k < a.Size; ++k) {
FindAllObjects(reader, a[k], hits);
}
return;
case PdfObject.DICTIONARY:
case PdfObject.STREAM:
PdfDictionary dic = (PdfDictionary)obj;
foreach (PdfName name in dic.Keys) {
FindAllObjects(reader, dic.Get(name), hits);
}
return;
}
}
示例4: PdfStamperImp
/** Creates new PdfStamperImp.
* @param reader the read PDF
* @param os the output destination
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original
* document
* @param append
* @throws DocumentException on error
* @throws IOException
*/
internal protected PdfStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append) : base(new PdfDocument(), os) {
if (!reader.IsOpenedWithFullPermissions)
throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));
if (reader.Tampered)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.original.document.was.reused.read.it.again.from.file"));
reader.Tampered = true;
this.reader = reader;
file = reader.SafeFile;
this.append = append;
if (reader.IsEncrypted() && (append || PdfReader.unethicalreading)) {
crypto = new PdfEncryption(reader.Decrypt);
}
if (append) {
if (reader.IsRebuilt())
throw new DocumentException(MessageLocalization.GetComposedMessage("append.mode.requires.a.document.without.errors.even.if.recovery.was.possible"));
pdf_version.SetAppendmode(true);
if (pdfVersion == 0) {
pdf_version.PdfVersion = reader.PdfVersion;
}
else {
pdf_version.PdfVersion = pdfVersion;
}
byte[] buf = new byte[8192];
int n;
while ((n = file.Read(buf)) > 0)
this.os.Write(buf, 0, n);
prevxref = reader.LastXref;
reader.Appendable = true;
}
else {
if (pdfVersion == 0)
base.PdfVersion = reader.PdfVersion;
else
base.PdfVersion = pdfVersion;
}
if (reader.IsTagged()) {
this.SetTagged();
}
base.Open();
pdf.AddWriter(this);
if (append) {
body.Refnum = reader.XrefSize;
marked = new IntHashtable();
if (reader.IsNewXrefType())
fullCompression = true;
if (reader.IsHybridXref())
fullCompression = false;
}
initialXrefSize = reader.XrefSize;
ReadColorProfile();
}
示例5: GetBookmark
/**
* Gets a <CODE>List</CODE> with the bookmarks that are children of <CODE>outline</CODE>. It returns <CODE>null</CODE> if
* the document doesn't have any bookmarks.
* @param reader the document
* @param outline the outline dictionary to get bookmarks from
* @param includeRoot indicates if to include <CODE>outline</CODE> parameter itself into returned list of bookmarks
* @return a <CODE>List</CODE> with the bookmarks or <CODE>null</CODE> if the
* document doesn't have any
*/
public static IList<Dictionary<String, Object>> GetBookmark(PdfReader reader, PdfDictionary outline, bool includeRoot) {
if (outline == null)
return null;
IntHashtable pages = new IntHashtable();
int numPages = reader.NumberOfPages;
for (int k = 1; k <= numPages; ++k) {
pages[reader.GetPageOrigRef(k).Number] = k;
reader.ReleasePage(k);
}
if (includeRoot)
return BookmarkDepth(reader, outline, pages, true);
else
return BookmarkDepth(reader, (PdfDictionary)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.FIRST)), pages, false);
}
示例6: InstHit
public InstHit(int[] inst)
{
if (inst == null)
return;
hits = new IntHashtable();
for (int k = 0; k < inst.Length; ++k)
hits[inst[k]] = 1;
}
示例7: MapGotoBookmark
private static void MapGotoBookmark(Dictionary<String, Object> map, PdfObject dest, IntHashtable pages)
{
if (dest.IsString())
map["Named"] = dest.ToString();
else if (dest.IsName())
map["Named"] = PdfName.DecodeName(dest.ToString());
else if (dest.IsArray())
map["Page"] = MakeBookmarkParam((PdfArray)dest, pages); //changed by ujihara 2004-06-13
map["Action"] = "GoTo";
}
示例8: MakeBookmarkParam
private static String MakeBookmarkParam(PdfArray dest, IntHashtable pages)
{
StringBuilder s = new StringBuilder();
PdfObject obj = dest[0];
if (obj.IsNumber())
s.Append(((PdfNumber)obj).IntValue + 1);
else
s.Append(pages[GetNumber((PdfIndirectReference)obj)]); //changed by ujihara 2004-06-13
s.Append(' ').Append(dest[1].ToString().Substring(1));
for (int k = 2; k < dest.Size; ++k)
s.Append(' ').Append(dest[k].ToString());
return s.ToString();
}
示例9: PdfStamperImp
/** Creates new PdfStamperImp.
* @param reader the read PDF
* @param os the output destination
* @param pdfVersion the new pdf version or '\0' to keep the same version as the original
* document
* @param append
* @throws DocumentException on error
* @throws IOException
*/
internal PdfStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append)
: base(new PdfDocument(), os)
{
if (reader.Tampered)
throw new DocumentException("The original document was reused. Read it again from file.");
reader.Tampered = true;
this.reader = reader;
file = reader.SafeFile;
this.append = append;
if (append) {
if (reader.IsRebuilt())
throw new DocumentException("Append mode requires a document without errors even if recovery was possible.");
if (reader.IsEncrypted())
crypto = new PdfEncryption(reader.Decrypt);
pdf_version.SetAppendmode(true);
file.ReOpen();
byte[] buf = new byte[8192];
int n;
while ((n = file.Read(buf)) > 0)
this.os.Write(buf, 0, n);
file.Close();
prevxref = reader.LastXref;
reader.Appendable = true;
}
else {
if (pdfVersion == 0)
base.PdfVersion = reader.PdfVersion;
else
base.PdfVersion = pdfVersion;
}
base.Open();
pdf.AddWriter(this);
if (append) {
body.Refnum = reader.XrefSize;
marked = new IntHashtable();
if (reader.IsNewXrefType())
fullCompression = true;
if (reader.IsHybridXref())
fullCompression = false;
}
initialXrefSize = reader.XrefSize;
}
示例10: RegisterReader
/**
* @param reader
* @param openFile
* @throws IOException
*/
virtual public void RegisterReader(PdfReader reader, bool openFile) {
if (readers2intrefs.ContainsKey(reader))
return;
readers2intrefs[reader] = new IntHashtable();
if (openFile) {
RandomAccessFileOrArray raf = reader.SafeFile;
readers2file[reader] = raf;
raf.ReOpen();
}
}
示例11: AddComments
/**
* @param fdf
* @throws IOException
*/
virtual public void AddComments(FdfReader fdf) {
if (readers2intrefs.ContainsKey(fdf))
return;
PdfDictionary catalog = fdf.Catalog;
catalog = catalog.GetAsDict(PdfName.FDF);
if (catalog == null)
return;
PdfArray annots = catalog.GetAsArray(PdfName.ANNOTS);
if (annots == null || annots.Size == 0)
return;
RegisterReader(fdf, false);
IntHashtable hits = new IntHashtable();
Dictionary<String, PdfObject> irt = new Dictionary<string,PdfObject>();
List<PdfObject> an = new List<PdfObject>();
for (int k = 0; k < annots.Size; ++k) {
PdfObject obj = annots[k];
PdfDictionary annot = (PdfDictionary)PdfReader.GetPdfObject(obj);
PdfNumber page = annot.GetAsNumber(PdfName.PAGE);
if (page == null || page.IntValue >= reader.NumberOfPages)
continue;
FindAllObjects(fdf, obj, hits);
an.Add(obj);
if (obj.Type == PdfObject.INDIRECT) {
PdfObject nm = PdfReader.GetPdfObject(annot.Get(PdfName.NM));
if (nm != null && nm.Type == PdfObject.STRING)
irt[nm.ToString()] = obj;
}
}
int[] arhits = hits.GetKeys();
for (int k = 0; k < arhits.Length; ++k) {
int n = arhits[k];
PdfObject obj = fdf.GetPdfObject(n);
if (obj.Type == PdfObject.DICTIONARY) {
PdfObject str = PdfReader.GetPdfObject(((PdfDictionary)obj).Get(PdfName.IRT));
if (str != null && str.Type == PdfObject.STRING) {
PdfObject i;
irt.TryGetValue(str.ToString(), out i);
if (i != null) {
PdfDictionary dic2 = new PdfDictionary();
dic2.Merge((PdfDictionary)obj);
dic2.Put(PdfName.IRT, i);
obj = dic2;
}
}
}
AddToBody(obj, GetNewObjectNumber(fdf, n, 0));
}
for (int k = 0; k < an.Count; ++k) {
PdfObject obj = an[k];
PdfDictionary annot = (PdfDictionary)PdfReader.GetPdfObject(obj);
PdfNumber page = annot.GetAsNumber(PdfName.PAGE);
PdfDictionary dic = reader.GetPageN(page.IntValue + 1);
PdfArray annotsp = (PdfArray)PdfReader.GetPdfObject(dic.Get(PdfName.ANNOTS), dic);
if (annotsp == null) {
annotsp = new PdfArray();
dic.Put(PdfName.ANNOTS, annotsp);
MarkUsed(dic);
}
MarkUsed(annotsp);
annotsp.Add(obj);
}
}
示例12: BookmarkDepth
private static IList<Dictionary<String, Object>> BookmarkDepth(PdfReader reader, PdfDictionary outline, IntHashtable pages, bool processCurrentOutlineOnly) {
List<Dictionary<String, Object>> list = new List<Dictionary<String, Object>>();
while (outline != null) {
Dictionary<String, Object> map = new Dictionary<string,object>();
PdfString title = (PdfString)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.TITLE));
map["Title"] = title.ToUnicodeString();
PdfArray color = (PdfArray)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.C));
if (color != null && color.Size == 3) {
ByteBuffer outp = new ByteBuffer();
outp.Append(color.GetAsNumber(0).FloatValue).Append(' ');
outp.Append(color.GetAsNumber(1).FloatValue).Append(' ');
outp.Append(color.GetAsNumber(2).FloatValue);
map["Color"] = PdfEncodings.ConvertToString(outp.ToByteArray(), null);
}
PdfNumber style = (PdfNumber)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.F));
if (style != null) {
int f = style.IntValue;
String s = "";
if ((f & 1) != 0)
s += "italic ";
if ((f & 2) != 0)
s += "bold ";
s = s.Trim();
if (s.Length != 0)
map["Style"] = s;
}
PdfNumber count = (PdfNumber)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.COUNT));
if (count != null && count.IntValue < 0)
map["Open"] = "false";
try {
PdfObject dest = PdfReader.GetPdfObjectRelease(outline.Get(PdfName.DEST));
if (dest != null) {
MapGotoBookmark(map, dest, pages); //changed by ujihara 2004-06-13
}
else {
PdfDictionary action = (PdfDictionary)PdfReader.GetPdfObjectRelease(outline.Get(PdfName.A));
if (action != null) {
if (PdfName.GOTO.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
dest = PdfReader.GetPdfObjectRelease(action.Get(PdfName.D));
if (dest != null) {
MapGotoBookmark(map, dest, pages);
}
}
else if (PdfName.URI.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
map["Action"] = "URI";
map["URI"] = ((PdfString)PdfReader.GetPdfObjectRelease(action.Get(PdfName.URI))).ToUnicodeString();
}
else if (PdfName.JAVASCRIPT.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
map["Action"] = "JS";
map["Code"] = PdfReader.GetPdfObjectRelease(action.Get(PdfName.JS)).ToString();
}
else if (PdfName.GOTOR.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
dest = PdfReader.GetPdfObjectRelease(action.Get(PdfName.D));
if (dest != null) {
if (dest.IsString())
map["Named"] = dest.ToString();
else if (dest.IsName())
map["NamedN"] = PdfName.DecodeName(dest.ToString());
else if (dest.IsArray()) {
PdfArray arr = (PdfArray)dest;
StringBuilder s = new StringBuilder();
s.Append(arr[0].ToString());
s.Append(' ').Append(arr[1].ToString());
for (int k = 2; k < arr.Size; ++k)
s.Append(' ').Append(arr[k].ToString());
map["Page"] = s.ToString();
}
}
map["Action"] = "GoToR";
PdfObject file = PdfReader.GetPdfObjectRelease(action.Get(PdfName.F));
if (file != null) {
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
else if (file.IsDictionary()) {
file = PdfReader.GetPdfObject(((PdfDictionary)file).Get(PdfName.F));
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
}
}
PdfObject newWindow = PdfReader.GetPdfObjectRelease(action.Get(PdfName.NEWWINDOW));
if (newWindow != null)
map["NewWindow"] = newWindow.ToString();
}
else if (PdfName.LAUNCH.Equals(PdfReader.GetPdfObjectRelease(action.Get(PdfName.S)))) {
map["Action"] = "Launch";
PdfObject file = PdfReader.GetPdfObjectRelease(action.Get(PdfName.F));
if (file == null)
file = PdfReader.GetPdfObjectRelease(action.Get(PdfName.WIN));
if (file != null) {
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
else if (file.IsDictionary()) {
file = PdfReader.GetPdfObjectRelease(((PdfDictionary)file).Get(PdfName.F));
if (file.IsString())
map["File"] = ((PdfString)file).ToUnicodeString();
}
}
}
}
}
//.........这里部分代码省略.........
示例13: SymbolConversion
internal SymbolConversion(bool symbol) {
if (symbol) {
translation = t1;
byteToChar = table1;
} else {
translation = t2;
byteToChar = table2;
}
}