DocX icon indicating copy to clipboard operation
DocX copied to clipboard

Formatting in list items

Open bukharin opened this issue 8 years ago • 6 comments

How to apply text formatting in list ?

bukharin avatar Sep 08 '16 17:09 bukharin

Looking for this too, please help!

verreaultfrank avatar Mar 22 '18 19:03 verreaultfrank

Hi,

You can set a font + fontSize for all items of a list : document.InsertList( bulletedList, new Xceed.Document.NET.Font( "Cooper Black"), 15 );

or you can format any listItem : bulletedList.Items[ 2 ].Color( Color.Red );

XceedBoucherS avatar Mar 26 '18 19:03 XceedBoucherS

Hi!

Cant find how to change points on a dash in list.

For example i have: image

And i need:

image

Help me please :)

Externum avatar Jul 09 '20 13:07 Externum

I don't think this is currently possible. Will look into this. Thanks for pointing this out.

XceedBoucherS avatar Jul 13 '20 19:07 XceedBoucherS

Oh... ok :( Thanks.

Externum avatar Jul 14 '20 10:07 Externum

This feature is now available in Plus version since release 1.9.

In List, the ListOptions property can now be used to get/set the list configuration, including the list type, the list modification tracking, and the list levels configuration.


    /// <summary>
    /// Create a custom numbered list with different listItem's levels, items and numbering formatting.
    /// </summary>
    public static void AddCustomNumberedList()
    {
      Console.WriteLine( "\tAddCustomNumberedList()" );

      // Create a document.
      using( var document = DocX.Create( ListSample.ListSampleOutputDirectory + @"AddCustomNumberedList.docx" ) )
      {
        // Add a title
        document.InsertParagraph( "Adding a custom numbered list into a document" ).FontSize( 15d ).SpacingAfter( 50d ).Alignment = Alignment.center;

        // Add a custom numbered list.
        // Create the list levels configuration
        var customNumberedListOptions = new ListOptions()
        {
          ListType = ListItemType.Numbered,

          LevelsConfigs = new ObservableCollection<ListLevelConfig>()
            {
               new ListLevelConfig()
                   {
                      NumberingFormat = NumberingFormat.upperRoman,
                      NumberingLevelText = "%1)",
                      Justification = Justification.left,
                      Indentation = new Indentation()
                      {
                        Hanging = 18f,
                        Left = 16f
                      },
                      Formatting = new Formatting()
                      {
                        FontColor = Color.DarkMagenta,
                        Bold = true
                      }
               },
                 new ListLevelConfig()

                   {
                      NumberingFormat = NumberingFormat.lowerRoman,
                      NumberingLevelText = "%2.",
                      Justification = Justification.left,
                      Formatting = new Formatting()
                      {
                        FontColor = Color.Blue,
                        Bold = true
                      }
                   }
              ,

              new ListLevelConfig()
              {
                NumberingFormat = NumberingFormat.decimalNormal,
                NumberingLevelText = "%3.",
                Justification = Justification.left
              }
            ,
              new ListLevelConfig()
              {
                NumberingFormat = NumberingFormat.bullet,
                NumberingLevelText = "*",
                Justification = Justification.left
              }
            }

        };

        // Create a numbered list with the specified list options.
        var customNumberedList = document.AddList( customNumberedListOptions );
        // Add first item in the list.
        customNumberedList.AddListItem( "Cars" );
        // Add Sub-items(level 1) to the preceding ListItem.
        customNumberedList.AddListItem( "Cadillac", 1 );
        customNumberedList.AddListItem( "Mercedes-Benz", 1 );
        // Add Sub-items(level 2) to the preceding ListItem.
        customNumberedList.AddListItem( "SUVs", 2 );
        // Add Sub-items(level 3) to the preceding ListItem.
        customNumberedList.AddListItem( "GLA SUV", 3 );
        // Add Sub-items(level 4) to the preceding ListItem.
        customNumberedList.AddListItem( "GLA 250 4MATIC SUV", 4 );
        customNumberedList.AddListItem( "AMG GLA 35 4MATIC SUV", 4 );
        // Add Sub-items(level 5) to the preceding ListItem.
        customNumberedList.AddListItem( "AMG-enhanced 2.0L inline-4 turbo Engine", 5 );
        customNumberedList.AddListItem( "AMG SPEEDSHIFT DCT 8-speed dual-clutch Automatic", 5 );
        customNumberedList.AddListItem( "AMG GLA 45 4MATIC SUV", 4 );
        customNumberedList.AddListItem( "GLB SUV", 3 );
        customNumberedList.AddListItem( "GLC SUV", 3 );
        customNumberedList.AddListItem( "GLE SUV Coupe", 3 );
        customNumberedList.AddListItem( "Sedans & Wagons", 2 );
        // Add Sub-items(level 3) to the preceding ListItem.
        customNumberedList.AddListItem( "A-Class Hatch", 3 );
        customNumberedList.AddListItem( "A-Class Sedan", 3 );
        customNumberedList.AddListItem( "C-Class Sedan", 3 );
        customNumberedList.AddListItem( "Coupes", 2 );
        customNumberedList.AddListItem( "Convertibles & Roadsters", 2 );
        // Add more items at level 1.
        customNumberedList.AddListItem( "Maybach", 1 );
        customNumberedList.AddListItem( "Toyota", 1 );
        customNumberedList.AddListItem( "BMW", 1 );
        // Add an item (level 0)
        customNumberedList.AddListItem( "Boats" );
        customNumberedList.AddListItem( "Dinghies", 1 );
        customNumberedList.AddListItem( "Fish-and-ski Boat", 1 );
        customNumberedList.AddListItem( "Sportfishing Yachts", 1 );
        customNumberedList.AddListItem( "Trawlers", 1 );
        // Add an item (level 0)
        customNumberedList.AddListItem( "Planes" );
        // Add Sub-items(level 1) to the preceding ListItem.
        customNumberedList.AddListItem( "Aerospatiale", 1 );
        customNumberedList.AddListItem( "Boeing", 1 );
        customNumberedList.AddListItem( "Bombardier", 1 );
        customNumberedList.AddListItem( "Eclipse Aerospace", 1 );
        customNumberedList.AddListItem( "Embraer", 1 );

        // Insert the list into the document.
        document.InsertParagraph( "This is a custom Numbered List:\n" );
        document.InsertList( customNumberedList );

        document.Save();
        Console.WriteLine( "\tCreated: AddCustomNumberedList.docx\n" );
      }
    }

 public class ListSymbol
  {
    public string FontName;
    public int Code;

    public ListSymbol( string fontName, int code )
    {
      this.FontName = fontName;
      this.Code = code;
    }

    public string UnicodeToString()
    {
      return char.ConvertFromUtf32( this.Code );
    }
  }

evancekafando avatar Sep 15 '21 16:09 evancekafando