public virtual void PdtIndirectReferenceLateInitializing1() { MemoryStream baos = new MemoryStream(); PdfDocument document = new PdfDocument(new PdfWriter(baos)); document.AddNewPage(); PdfDictionary catalog = document.GetCatalog().GetPdfObject(); PdfIndirectReference indRef = document.CreateNextIndirectReference(); catalog.Put(new PdfName("Smth"), indRef); PdfDictionary dictionary = new PdfDictionary(); dictionary.Put(new PdfName("A"), new PdfString("a")); dictionary.MakeIndirect(document, indRef); document.Close(); MemoryStream bais = new MemoryStream(baos.ToArray()); document = new PdfDocument(new PdfReader(bais)); PdfObject @object = document.GetCatalog().GetPdfObject().Get(new PdfName("Smth")); NUnit.Framework.Assert.IsTrue(@object is PdfDictionary); dictionary = (PdfDictionary)@object; PdfString a = (PdfString)dictionary.Get(new PdfName("A")); NUnit.Framework.Assert.IsTrue(a.GetValue().Equals("a")); document.Close(); }
public virtual void CopySelfContainedObject() { ByteArrayOutputStream inputBytes = new ByteArrayOutputStream(); PdfDocument prepInputDoc = new PdfDocument(new PdfWriter(inputBytes)); PdfDictionary selfContainedDict = new PdfDictionary(); PdfName randDictName = PdfName.Sound; PdfName randEntry1 = PdfName.R; PdfName randEntry2 = PdfName.S; selfContainedDict.Put(randEntry1, selfContainedDict); selfContainedDict.Put(randEntry2, selfContainedDict); prepInputDoc.AddNewPage().Put(randDictName, selfContainedDict.MakeIndirect(prepInputDoc)); prepInputDoc.Close(); PdfDocument srcDoc = new PdfDocument(new PdfReader(new MemoryStream(inputBytes.ToArray()))); PdfDocument destDoc = new PdfDocument(new PdfWriter(destinationFolder + "copySelfContainedObject.pdf")); srcDoc.CopyPagesTo(1, 1, destDoc); PdfDictionary destPageObj = destDoc.GetFirstPage().GetPdfObject(); PdfDictionary destSelfContainedDict = destPageObj.GetAsDictionary(randDictName); PdfDictionary destSelfContainedDictR = destSelfContainedDict.GetAsDictionary(randEntry1); PdfDictionary destSelfContainedDictS = destSelfContainedDict.GetAsDictionary(randEntry2); NUnit.Framework.Assert.AreEqual(destSelfContainedDict.GetIndirectReference(), destSelfContainedDictR.GetIndirectReference ()); NUnit.Framework.Assert.AreEqual(destSelfContainedDict.GetIndirectReference(), destSelfContainedDictS.GetIndirectReference ()); destDoc.Close(); srcDoc.Close(); }
public virtual void RemoveUnusedObjectsInStampingModeTest() { String filenameIn = "docWithUnusedObjects_1.pdf"; String filenameOut = "removeUnusedObjectsInStamping.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationFolder + filenameIn)); pdfDocument.AddNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); PdfArray unusedArray = (PdfArray) new PdfArray().MakeIndirect(pdfDocument); unusedArray.Add(new PdfNumber(42)); unusedDictionary.Put(new PdfName("testName"), unusedArray); unusedDictionary.MakeIndirect(pdfDocument).Flush(); pdfDocument.Close(); PdfDocument doc = new PdfDocument(new PdfReader(destinationFolder + filenameIn), new PdfWriter(destinationFolder + filenameOut)); NUnit.Framework.Assert.AreEqual(doc.GetXref().Size(), 8); //on closing, all unused objects shall not be written to resultant document doc.Close(); PdfDocument testerDocument = new PdfDocument(new PdfReader(destinationFolder + filenameOut)); NUnit.Framework.Assert.AreEqual(testerDocument.GetXref().Size(), 6); testerDocument.Close(); }
public virtual void AddUnusedObjectsInStampingModeTest() { String filenameIn = "docWithUnusedObjects_2.pdf"; String filenameOut = "addUnusedObjectsInStamping.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationFolder + filenameIn)); pdfDocument.AddNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); PdfArray unusedArray = (PdfArray) new PdfArray().MakeIndirect(pdfDocument); unusedArray.Add(new PdfNumber(42)); unusedDictionary.Put(new PdfName("testName"), unusedArray); unusedDictionary.MakeIndirect(pdfDocument).Flush(); pdfDocument.Close(); PdfDocument doc = new PdfDocument(new PdfReader(destinationFolder + filenameIn), new PdfWriter(destinationFolder + filenameOut)); NUnit.Framework.Assert.AreEqual(doc.GetXref().Size(), 8); doc.SetFlushUnusedObjects(true); doc.Close(); PdfDocument testerDocument = new PdfDocument(new PdfReader(destinationFolder + filenameOut)); NUnit.Framework.Assert.AreEqual(testerDocument.GetXref().Size(), 8); testerDocument.Close(); }
public virtual void CopyPagesWithOCGSameObject() { byte[] docBytes; using (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { using (PdfDocument document = new PdfDocument(new PdfWriter(outputStream))) { PdfPage page = document.AddNewPage(); PdfResources pdfResource = page.GetResources(); PdfDictionary ocg = new PdfDictionary(); ocg.Put(PdfName.Type, PdfName.OCG); ocg.Put(PdfName.Name, new PdfString("name1")); ocg.MakeIndirect(document); pdfResource.AddProperties(ocg); PdfPage page2 = document.AddNewPage(); PdfResources pdfResource2 = page2.GetResources(); pdfResource2.AddProperties(ocg); document.GetCatalog().GetOCProperties(true); } docBytes = outputStream.ToArray(); } using (PdfDocument outDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { using (PdfDocument fromDocument = new PdfDocument(new PdfReader(new MemoryStream(docBytes)))) { fromDocument.CopyPagesTo(1, fromDocument.GetNumberOfPages(), outDocument); } IList <String> layerNames = new List <String>(); layerNames.Add("name1"); PdfDocumentUnitTest.AssertLayerNames(outDocument, layerNames); } }
public virtual void SmartModeObjectSelfReferencingTest() { PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream())); PdfDictionary dict1 = new PdfDictionary(); dict1.MakeIndirect(document); PdfDictionary dict2 = new PdfDictionary(); dict2.MakeIndirect(document); PdfArray array = new PdfArray(); array.MakeIndirect(document); array.Add(new PdfString(new byte[10000])); array.Add(new PdfDictionary(dict2)); dict1.Put(new PdfName("FirstDict"), array.GetIndirectReference()); dict2.Put(new PdfName("SecondDict"), dict1.GetIndirectReference()); SmartModePdfObjectsSerializer serializer = new SmartModePdfObjectsSerializer(); SerializedObjectContent serializedObject = serializer.SerializeObject(dict1); //It is essential to serialize object with huge amount of memory StringBuilder stringBytes = new StringBuilder().Append("$D$N/FirstDict$A$S"); String end = "$D$\\D$\\A$\\D"; for (int i = 0; i < 10000; i++) { stringBytes.Append("\x0"); } stringBytes.Append(end); SerializedObjectContent expected = new SerializedObjectContent(stringBytes.ToString().GetBytes(System.Text.Encoding .UTF8)); NUnit.Framework.Assert.AreEqual(expected, serializedObject); }
/// <summary>Create a PdfDocumentInfo based on the passed PdfDictionary.</summary> /// <param name="pdfObject">PdfDictionary containing PdfDocumentInfo</param> internal PdfDocumentInfo(PdfDictionary pdfObject, PdfDocument pdfDocument) { infoDictionary = pdfObject; if (pdfDocument.GetWriter() != null) { infoDictionary.MakeIndirect(pdfDocument); } }
/// <summary>Create instance of document outline.</summary> /// <param name="title">the text that shall be displayed on the screen for this item.</param> /// <param name="content">Outline dictionary</param> /// <param name="parent"> /// parent outline. /// <see cref="AddOutline(System.String, int)"/> /// and /// <see cref="AddOutline(System.String)"/> /// instead. /// </param> internal PdfOutline(String title, PdfDictionary content, iText.Kernel.Pdf.PdfOutline parent) { this.title = title; this.content = content; this.parent = parent; this.pdfDoc = parent.pdfDoc; content.MakeIndirect(parent.pdfDoc); }
/// <summary>This constructor creates root outline in the document.</summary> /// <param name="doc"> /// /// <see cref="PdfDocument"/> /// </param> internal PdfOutline(PdfDocument doc) { content = new PdfDictionary(); content.Put(PdfName.Type, PdfName.Outlines); this.pdfDoc = doc; content.MakeIndirect(doc); doc.GetCatalog().AddRootOutline(this); }
public virtual void FreeReferencesInObjectStream() { PdfReader reader = new PdfReader(sourceFolder + "styledLineArts_Redacted.pdf"); PdfWriter writer = new PdfWriter(new MemoryStream()); PdfDocument document = new PdfDocument(reader, writer, new StampingProperties().UseAppendMode()); PdfDictionary dict = new PdfDictionary(); dict.MakeIndirect(document); NUnit.Framework.Assert.IsTrue(dict.GetIndirectReference().GetObjNumber() > 0); }
private static byte[] InitDocument(IList <String> names) { using (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { using (PdfDocument document = new PdfDocument(new PdfWriter(outputStream))) { PdfPage page = document.AddNewPage(); PdfResources pdfResource = page.GetResources(); foreach (String name in names) { PdfDictionary ocg = new PdfDictionary(); ocg.Put(PdfName.Type, PdfName.OCG); ocg.Put(PdfName.Name, new PdfString(name)); ocg.MakeIndirect(document); pdfResource.AddProperties(ocg); } document.GetCatalog().GetOCProperties(true); } return(outputStream.ToArray()); } }
public virtual void PdtIndirectReferenceLateInitializing3() { MemoryStream baos = new MemoryStream(); PdfWriter writer = new PdfWriter(baos); PdfDocument document = new PdfDocument(writer); document.AddNewPage(); PdfDictionary catalog = document.GetCatalog().GetPdfObject(); PdfIndirectReference indRef1 = document.CreateNextIndirectReference(); PdfIndirectReference indRef2 = document.CreateNextIndirectReference(); PdfArray array = new PdfArray(); catalog.Put(new PdfName("array1"), array); PdfString @string = new PdfString("array string"); array.Add(@string); array.Add(indRef1); array.Add(indRef2); PdfDictionary dict = new PdfDictionary(); dict.MakeIndirect(document, indRef1); PdfArray arrayClone = (PdfArray)array.Clone(); PdfObject object0 = arrayClone.Get(0, false); PdfObject object1 = arrayClone.Get(1, false); PdfObject object2 = arrayClone.Get(2, false); NUnit.Framework.Assert.IsTrue(object0 is PdfString); NUnit.Framework.Assert.IsTrue(object1 is PdfDictionary); NUnit.Framework.Assert.IsTrue(object2 is PdfNull); PdfString string1 = (PdfString)object0; NUnit.Framework.Assert.IsTrue(@string != string1); NUnit.Framework.Assert.IsTrue(@string.GetValue().Equals(string1.GetValue())); PdfDictionary dict1 = (PdfDictionary)object1; NUnit.Framework.Assert.IsTrue(dict1.GetIndirectReference().GetObjNumber() == dict.GetIndirectReference().GetObjNumber ()); NUnit.Framework.Assert.IsTrue(dict1.GetIndirectReference().GetGenNumber() == dict.GetIndirectReference().GetGenNumber ()); NUnit.Framework.Assert.IsTrue(dict1 == dict); document.Close(); }
public virtual void AddUnusedObjectsInWriterModeTest() { String filename = "addUnusedObjectsInWriter.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(DESTINATION_FOLDER + filename)); pdfDocument.AddNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); PdfArray unusedArray = (PdfArray) new PdfArray().MakeIndirect(pdfDocument); unusedArray.Add(new PdfNumber(42)); unusedDictionary.Put(new PdfName("testName"), unusedArray); unusedDictionary.MakeIndirect(pdfDocument); NUnit.Framework.Assert.AreEqual(pdfDocument.GetXref().Size(), 8); pdfDocument.SetFlushUnusedObjects(true); pdfDocument.Close(); PdfDocument testerDocument = new PdfDocument(new PdfReader(DESTINATION_FOLDER + filename)); NUnit.Framework.Assert.AreEqual(testerDocument.GetXref().Size(), 8); testerDocument.Close(); }
public virtual void RemoveUnusedObjectsInWriterModeTest() { String filename = "removeUnusedObjectsInWriter.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(DESTINATION_FOLDER + filename)); pdfDocument.AddNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); PdfArray unusedArray = (PdfArray) new PdfArray().MakeIndirect(pdfDocument); unusedArray.Add(new PdfNumber(42)); unusedDictionary.Put(new PdfName("testName"), unusedArray); unusedDictionary.MakeIndirect(pdfDocument); NUnit.Framework.Assert.AreEqual(pdfDocument.GetXref().Size(), 8); //on closing, all unused objects shall not be written to resultant document pdfDocument.Close(); PdfDocument testerDocument = new PdfDocument(new PdfReader(DESTINATION_FOLDER + filename)); NUnit.Framework.Assert.AreEqual(testerDocument.GetXref().Size(), 6); testerDocument.Close(); }
public virtual void EmbeddedFileAddedInAppendModeTest() { //Create input document MemoryStream boasEmpty = new MemoryStream(); PdfWriter emptyDocWriter = new PdfWriter(boasEmpty); PdfDocument emptyDoc = new PdfDocument(emptyDocWriter); emptyDoc.AddNewPage(); PdfDictionary emptyNamesDic = new PdfDictionary(); emptyNamesDic.MakeIndirect(emptyDoc); emptyDoc.GetCatalog().GetPdfObject().Put(PdfName.Names, emptyNamesDic); emptyDoc.Close(); //Create input document MemoryStream boasAttached = new MemoryStream(); PdfWriter attachDocWriter = new PdfWriter(boasAttached); PdfDocument attachDoc = new PdfDocument(attachDocWriter); attachDoc.AddNewPage(); attachDoc.Close(); //Attach file in append mode PdfReader appendReader = new PdfReader(new MemoryStream(boasEmpty.ToArray())); MemoryStream boasAppend = new MemoryStream(); PdfWriter appendWriter = new PdfWriter(boasAppend); PdfDocument appendDoc = new PdfDocument(appendReader, appendWriter, new StampingProperties().UseAppendMode ()); appendDoc.AddFileAttachment("Test File", PdfFileSpec.CreateEmbeddedFileSpec(appendDoc, boasAttached.ToArray (), "Append Embedded File test", "Test file", null)); appendDoc.Close(); //Check final result PdfReader finalReader = new PdfReader(new MemoryStream(boasAppend.ToArray())); PdfDocument finalDoc = new PdfDocument(finalReader); PdfNameTree embeddedFilesNameTree = finalDoc.GetCatalog().GetNameTree(PdfName.EmbeddedFiles); IDictionary <String, PdfObject> embeddedFilesMap = embeddedFilesNameTree.GetNames(); NUnit.Framework.Assert.IsTrue(embeddedFilesMap.Count > 0); NUnit.Framework.Assert.IsTrue(embeddedFilesMap.ContainsKey("Test File")); }
public virtual void AddUnusedObjectsInWriterModeTest() { String filename = "addUnusedObjectsInWriter.pdf"; PdfWriter writer = new PdfWriter(new FileStream(destinationFolder + filename, FileMode.Create)); PdfDocument pdfDocument = new PdfDocument(writer); pdfDocument.AddNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); PdfArray unusedArray = ((PdfArray) new PdfArray().MakeIndirect(pdfDocument)); unusedArray.Add(new PdfNumber(42)); unusedDictionary.Put(new PdfName("testName"), unusedArray); unusedDictionary.MakeIndirect(pdfDocument); NUnit.Framework.Assert.AreEqual(pdfDocument.GetXref().Size(), 8); pdfDocument.SetFlushUnusedObjects(true); pdfDocument.Close(); PdfReader testerReader = new PdfReader(destinationFolder + filename); PdfDocument testerDocument = new PdfDocument(testerReader); NUnit.Framework.Assert.AreEqual(testerDocument.GetXref().Size(), 8); testerDocument.Close(); }
public virtual void AddUnusedStreamObjectsTest() { String filenameIn = "docWithUnusedObjects_3.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationFolder + filenameIn)); pdfDocument.AddNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); PdfArray unusedArray = (PdfArray) new PdfArray().MakeIndirect(pdfDocument); unusedArray.Add(new PdfNumber(42)); PdfStream stream = new PdfStream(new byte[] { 1, 2, 34, 45 }, 0); unusedArray.Add(stream); unusedDictionary.Put(new PdfName("testName"), unusedArray); unusedDictionary.MakeIndirect(pdfDocument).Flush(); pdfDocument.SetFlushUnusedObjects(true); pdfDocument.Close(); PdfDocument testerDocument = new PdfDocument(new PdfReader(destinationFolder + filenameIn)); NUnit.Framework.Assert.AreEqual(testerDocument.GetXref().Size(), 9); testerDocument.Close(); }
public virtual void CopyPagesFlushedResources() { byte[] docBytes; using (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { using (PdfDocument document = new PdfDocument(new PdfWriter(outputStream))) { PdfPage page = document.AddNewPage(); PdfResources pdfResource = page.GetResources(); PdfDictionary ocg = new PdfDictionary(); ocg.Put(PdfName.Type, PdfName.OCG); ocg.Put(PdfName.Name, new PdfString("name1")); ocg.MakeIndirect(document); pdfResource.AddProperties(ocg); pdfResource.MakeIndirect(document); PdfPage page2 = document.AddNewPage(); page2.SetResources(pdfResource); document.GetCatalog().GetOCProperties(true); } docBytes = outputStream.ToArray(); } PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); using (PdfDocument outDocument = new PdfDocument(writer)) { using (PdfDocument fromDocument = new PdfDocument(new PdfReader(new MemoryStream(docBytes)))) { fromDocument.CopyPagesTo(1, 1, outDocument); IList <String> layerNames = new List <String>(); layerNames.Add("name1"); PdfDocumentUnitTest.AssertLayerNames(outDocument, layerNames); outDocument.FlushCopiedObjects(fromDocument); fromDocument.CopyPagesTo(2, 2, outDocument); NUnit.Framework.Assert.IsNotNull(outDocument.GetCatalog()); PdfOCProperties ocProperties = outDocument.GetCatalog().GetOCProperties(false); NUnit.Framework.Assert.IsNotNull(ocProperties); NUnit.Framework.Assert.AreEqual(1, ocProperties.GetLayers().Count); PdfLayer layer = ocProperties.GetLayers()[0]; NUnit.Framework.Assert.IsTrue(layer.GetPdfObject().IsFlushed()); } } }
public virtual void FlushSelfContainingObjectsWritingMode() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new MemoryStream())); PdfDictionary pageDict = pdfDoc.AddNewPage().GetPdfObject(); PdfDictionary dict1 = new PdfDictionary(); pageDict.Put(new PdfName("dict1"), dict1); PdfArray arr1 = new PdfArray(); pageDict.Put(new PdfName("arr1"), arr1); dict1.Put(new PdfName("dict1"), dict1); dict1.Put(new PdfName("arr1"), arr1); arr1.Add(arr1); arr1.Add(dict1); arr1.MakeIndirect(pdfDoc); dict1.MakeIndirect(pdfDoc); PageFlushingHelper flushingHelper = new PageFlushingHelper(pdfDoc); flushingHelper.UnsafeFlushDeep(1); NUnit.Framework.Assert.IsTrue(dict1.IsFlushed()); NUnit.Framework.Assert.IsTrue(arr1.IsFlushed()); pdfDoc.Close(); }
public virtual PdfDictionary BuildTree() { int?[] numbers = new int?[items.Count]; numbers = items.Keys.ToArray(numbers); iText.IO.Util.JavaUtil.Sort(numbers); if (numbers.Length <= NODE_SIZE) { PdfDictionary dic = new PdfDictionary(); PdfArray ar = new PdfArray(); for (int k = 0; k < numbers.Length; ++k) { ar.Add(new PdfNumber((int)numbers[k])); ar.Add(items.Get(numbers[k])); } dic.Put(PdfName.Nums, ar); return(dic); } int skip = NODE_SIZE; PdfDictionary[] kids = new PdfDictionary[(numbers.Length + NODE_SIZE - 1) / NODE_SIZE]; for (int i = 0; i < kids.Length; ++i) { int offset = i * NODE_SIZE; int end = Math.Min(offset + NODE_SIZE, numbers.Length); PdfDictionary dic = new PdfDictionary(); PdfArray arr = new PdfArray(); arr.Add(new PdfNumber((int)numbers[offset])); arr.Add(new PdfNumber((int)numbers[end - 1])); dic.Put(PdfName.Limits, arr); arr = new PdfArray(); for (; offset < end; ++offset) { arr.Add(new PdfNumber((int)numbers[offset])); arr.Add(items.Get(numbers[offset])); } dic.Put(PdfName.Nums, arr); dic.MakeIndirect(catalog.GetDocument()); kids[i] = dic; } int top = kids.Length; while (true) { if (top <= NODE_SIZE) { PdfArray arr = new PdfArray(); for (int k = 0; k < top; ++k) { arr.Add(kids[k]); } PdfDictionary dic = new PdfDictionary(); dic.Put(PdfName.Kids, arr); return(dic); } skip *= NODE_SIZE; int tt = (numbers.Length + skip - 1) / skip; for (int k = 0; k < tt; ++k) { int offset = k * NODE_SIZE; int end = Math.Min(offset + NODE_SIZE, top); PdfDictionary dic = (PdfDictionary) new PdfDictionary().MakeIndirect(catalog.GetDocument()); PdfArray arr = new PdfArray(); arr.Add(new PdfNumber((int)numbers[k * skip])); arr.Add(new PdfNumber((int)numbers[Math.Min((k + 1) * skip, numbers.Length) - 1])); dic.Put(PdfName.Limits, arr); arr = new PdfArray(); for (; offset < end; ++offset) { arr.Add(kids[offset]); } dic.Put(PdfName.Kids, arr); kids[k] = dic; } top = tt; } }
public virtual PdfDictionary BuildTree() { String[] names = new String[items.Count]; names = items.Keys.ToArray(names); iText.IO.Util.JavaUtil.Sort(names); if (names.Length <= NODE_SIZE) { PdfDictionary dic = new PdfDictionary(); PdfArray ar = new PdfArray(); foreach (String name in names) { ar.Add(new PdfString(name, null)); ar.Add(items.Get(name)); } dic.Put(PdfName.Names, ar); return(dic); } int skip = NODE_SIZE; PdfDictionary[] kids = new PdfDictionary[(names.Length + NODE_SIZE - 1) / NODE_SIZE]; for (int k = 0; k < kids.Length; ++k) { int offset = k * NODE_SIZE; int end = Math.Min(offset + NODE_SIZE, names.Length); PdfDictionary dic = new PdfDictionary(); PdfArray arr = new PdfArray(); arr.Add(new PdfString(names[offset], null)); arr.Add(new PdfString(names[end - 1], null)); dic.Put(PdfName.Limits, arr); arr = new PdfArray(); for (; offset < end; ++offset) { arr.Add(new PdfString(names[offset], null)); arr.Add(items.Get(names[offset])); } dic.Put(PdfName.Names, arr); dic.MakeIndirect(catalog.GetDocument()); kids[k] = dic; } int top = kids.Length; while (true) { if (top <= NODE_SIZE) { PdfArray arr = new PdfArray(); for (int i = 0; i < top; ++i) { arr.Add(kids[i]); } PdfDictionary dic = new PdfDictionary(); dic.Put(PdfName.Kids, arr); return(dic); } skip *= NODE_SIZE; int tt = (names.Length + skip - 1) / skip; for (int i_1 = 0; i_1 < tt; ++i_1) { int offset = i_1 * NODE_SIZE; int end = Math.Min(offset + NODE_SIZE, top); PdfDictionary dic = ((PdfDictionary) new PdfDictionary().MakeIndirect(catalog.GetDocument())); PdfArray arr = new PdfArray(); arr.Add(new PdfString(names[i_1 * skip], null)); arr.Add(new PdfString(names[Math.Min((i_1 + 1) * skip, names.Length) - 1], null)); dic.Put(PdfName.Limits, arr); arr = new PdfArray(); for (; offset < end; ++offset) { arr.Add(kids[offset]); } dic.Put(PdfName.Kids, arr); kids[i_1] = dic; } top = tt; } }