Click or drag to resize

InlineCollection Class

Represents a collection of Inline derived elements.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentElementCollection
    SautinSoft.DocumentElementCollectionInline
      SautinSoft.DocumentInlineCollection

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 3.8.6.28 (3.8.6.28)
Syntax
public sealed class InlineCollection : ElementCollection<Inline>

The InlineCollection type exposes the following members.

Properties
  NameDescription
Public propertyContent
Gets the ContentRange of this collection.
(Inherited from ElementCollection.)
Public propertyCount
Gets the number of elements contained in this collection.
(Inherited from ElementCollection.)
Public propertyItem
Gets or sets the element at the specified index.
(Inherited from ElementCollectionT.)
Public propertySupportedElementTypes
Gets a sequence of ElementTypes that can be contained in this collection.
(Inherited from ElementCollection.)
Top
Methods
  NameDescription
Public methodAdd (Inherited from ElementCollectionT.)
Public methodClear
Removes all elements from this collection.
(Inherited from ElementCollection.)
Public methodContains (Inherited from ElementCollectionT.)
Public methodCopyTo(T, Int32) (Inherited from ElementCollectionT.)
Public methodCopyTo(Element, Int32)
Copies the entire collection to an Array, starting at a particular Array index.
(Inherited from ElementCollection.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator
Gets an enumerator that iterates through the collection.
(Inherited from ElementCollectionT.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf (Inherited from ElementCollectionT.)
Public methodInsert (Inherited from ElementCollectionT.)
Public methodRemove (Inherited from ElementCollectionT.)
Public methodCode exampleRemoveAt
Removes the element at the specified index.
(Inherited from ElementCollection.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodIListAdd
Adds an item to the IList.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodIListContains
Determines whether the IList contains a specific value.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodICollectionCopyTo
Copies the elements of the ICollection to an Array, starting at a particular Array index.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodIListIndexOf
Determines the index of a specific item in the IList.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodIListInsert
Inserts an item to the IList at the specified index.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate propertyIListIsFixedSize
Gets a value indicating whether the IList has a fixed size.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate propertyIListIsReadOnly
Gets a value indicating whether the IList is read-only.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate propertyICollectionTIsReadOnly (Inherited from ElementCollectionT.)
Explicit interface implementationPrivate propertyICollectionIsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
(Inherited from ElementCollection.)
Explicit interface implementationPrivate propertyIListItem
Gets or sets the element at the specified index.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodIListRemove
Removes the first occurrence of a specific object from the IList.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate methodIListRemoveAt
Removes the IList item at the specified index.
(Inherited from ElementCollection.)
Explicit interface implementationPrivate propertyICollectionSyncRoot
Gets an object that can be used to synchronize access to the ICollection.
(Inherited from ElementCollection.)
Top
Remarks

Although InlineCollection is a strongly typed collection of a Inline derived elements, not all Inline derived elements are supported in every InlineCollection.

For example, Inlines and ResultInlines support all Inline derived elements, and DisplayInlines doesn't support Hyperlink element.

Supported element types can be retrieved through SupportedElementTypes property.

Examples
Merge all paragraphs into a single in an existing PDF document in C#
using System;
using System.IO;
using System.Linq;
using SautinSoft.Document;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            MergeParagraphs();
        }
        /// <summary>
        /// Merge all paragraphs into a single in an existing PDF document.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/merge-paragraphs-in-pdf-document-net-csharp-vb.php
        /// </remarks>
        static void MergeParagraphs()
        {
            string inpFile = @"..\..\example.pdf";
            string outFile = @"Result.pdf";
            DocumentCore dc = DocumentCore.Load(inpFile);

            Paragraph firstPar = dc.GetChildElements(true, ElementType.Paragraph).First() as Paragraph;

            int lastIndex = firstPar.Inlines.Count;

            foreach (Paragraph par in dc.GetChildElements(true, ElementType.Paragraph).Reverse().Where(p => p != firstPar))
            {
                int last = lastIndex;
                foreach(Inline inline in par.Inlines)
                {
                    firstPar.Inlines.Insert(last++, inline.Clone(true));
                }
                par.Content.Delete();
            }

            dc.Save(outFile);
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(inpFile) { UseShellExecute = true });
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
        }
    }
}
Merge all paragraphs into a single in an existing PDF document in VB.Net
Imports System
Imports System.IO
Imports System.Linq
Imports SautinSoft.Document

Namespace Example
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            MergeParagraphs()
        End Sub
        ''' <summary>
        ''' Merge all paragraphs into a single in an existing PDF document.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://sautinsoft.com/products/document/examples/merge-paragraphs-in-pdf-document-net-csharp-vb.php
        ''' </remarks>
        Private Shared Sub MergeParagraphs()
            Dim inpFile As String = "..\example.pdf"
            Dim outFile As String = "Result.pdf"
            Dim dc As DocumentCore = DocumentCore.Load(inpFile)

            Dim firstPar As Paragraph = TryCast(dc.GetChildElements(True, ElementType.Paragraph).First(), Paragraph)

            Dim lastIndex As Integer = firstPar.Inlines.Count

            For Each par As Paragraph In dc.GetChildElements(True, ElementType.Paragraph).Reverse().Where(Function(p) p IsNot firstPar)
                Dim last As Integer = lastIndex
                For Each inline As Inline In par.Inlines
                    firstPar.Inlines.Insert(last, inline.Clone(True))
                    last += 1
                Next inline
                par.Content.Delete()
            Next par

            dc.Save(outFile)
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(inpFile) With {.UseShellExecute = True})
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also