Aspose.Pdf.Examples.CSharp.AsposePdfGenerator.UtilityFeatures.AddingList.DefineOwnFormat C# (CSharp) Method

DefineOwnFormat() public static method

public static DefineOwnFormat ( ) : void
return void
        public static void DefineOwnFormat()
        {

            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a list section 
            Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");

            // Set its list type as table of of contents
            tocSection.ListType = Aspose.Pdf.Generator.ListType.TableOfContents;

            // ExStart:DefineOwnFormat
            // Define the format of the four levels list by setting the left margins and
            // Text format settings of each level
            tocSection.ListFormatArray.Length = 4;
            tocSection.ListFormatArray[0].LeftMargin = 0;
            tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
            tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
            tocSection.ListFormatArray[1].LeftMargin = 10;
            tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;
            tocSection.ListFormatArray[1].TextInfo.FontSize = 10;
            tocSection.ListFormatArray[2].LeftMargin = 20;
            tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
            tocSection.ListFormatArray[3].LeftMargin = 30;
            tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true; 
            // ExEnd:DefineOwnFormat  

            // Add the list section to the sections collection of the Pdf document
            pdf1.Sections.Add(tocSection);

            dataDir = dataDir + "DefineOwnFormat_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);

        }