Coder Social home page Coder Social logo

Formatting in list items about docx HOT 6 OPEN

xceedsoftware avatar xceedsoftware commented on May 17, 2024
Formatting in list items

from docx.

Comments (6)

XceedBoucherS avatar XceedBoucherS commented on May 17, 2024 1

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 );

from docx.

verreaultfrank avatar verreaultfrank commented on May 17, 2024

Looking for this too, please help!

from docx.

Externum avatar Externum commented on May 17, 2024

Hi!

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

For example i have:
image

And i need:

image

Help me please :)

from docx.

XceedBoucherS avatar XceedBoucherS commented on May 17, 2024

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

from docx.

Externum avatar Externum commented on May 17, 2024

Oh... ok :(
Thanks.

from docx.

evancekafando avatar evancekafando commented on May 17, 2024

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 );
    }
  }

from docx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.