Class TextStyle

Class TextStyle

Nama dari : Aspose.Note Perhitungan: Aspose.Note.dll (25.4.0)

Menentukan gaya teks.

public sealed class TextStyle : Style
   {
       private Font _font;
       private bool _isBold;
       private bool _isItalic;
       private int _baselineShift;
       public bool IsBold
       {
           get { return _isBold; }
       }
       public int BaselineShift
       {
           get { return _baselineShift; }
       }
       private Font Font
       {
           get { return _font; }
           set { _font = value; }
       }
       public bool IsItalic
       {
           get { return _isItalic; }
           set { _isItalic = value; }
       }
   }

Inheritance

object Style TextStyle

anggota yang diwarisi

Style.GetHashCode() , Style.IsBold , Style.IsItalic , Style.IsUnderline , Style.IsStrikethrough , Style.IsSuperscript , Style.IsSubscript , Style.FontName , Style.FontSize , Style.FontColor , Style.Highlight , Style.FontStyle , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Mari kita menekankan judul halaman di antara tajuk lain dengan meningkatkan ukuran font.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   foreach (var title in document.Select(e => e.Title.TitleText))
   {
       title.ParagraphStyle.FontSize = 24;
       title.ParagraphStyle.IsBold = true;
       foreach (var run in title.TextRuns)
       {
           run.Style.FontSize = 24;
           run.Style.IsBold = true;
       }
   }
   document.Save(Path.Combine(dataDir, "ChangePageTitleStyle.pdf"));

Mari kita menekankan perubahan terkini teks dengan penekanan.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   var richTextNodes = document.GetChildNodes<RichText>().Where(e => e.LastModifiedTime >= DateTime.Today.AddDays(-7));
   foreach (var node in richTextNodes)
   {
       node.ParagraphStyle.Highlight = Color.DarkGreen;
       foreach (var run in node.TextRuns)
       {
           run.Style.Highlight = Color.DarkSeaGreen;
       }
   }
   document.Save(Path.Combine(dataDir, "HighlightAllRecentChanges.pdf"));

Menetapkan bahasa bukti untuk teks.

var document = new Document();
   var page = new Page();
   var outline = new Outline();
   var outlineElem = new OutlineElement();
   var text = new RichText() { ParagraphStyle = ParagraphStyle.Default };
   text.Append("United States", new TextStyle() { Language = CultureInfo.GetCultureInfo("en-US") })
       .Append(" Germany", new TextStyle() { Language = CultureInfo.GetCultureInfo("de-DE") })
       .Append(" China", new TextStyle() { Language = CultureInfo.GetCultureInfo("zh-CN") });
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   document.AppendChildLast(page);
   document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

Manipulasi dengan format teks menggunakan gaya paragraf.

var document = new Document();
   var page = new Page();
   var outline = new Outline();
   var outlineElem = new OutlineElement();
   var text = new RichText()
      {
         ParagraphStyle = new ParagraphStyle()
         {
            FontName = "Courier New",
            FontSize = 20
         }
      }
      .Append($"DefaultParagraphFontAndSize{Environment.NewLine}")
      .Append($"OnlyDefaultParagraphFont{Environment.NewLine}", new TextStyle() { FontSize = 14 })
      .Append("OnlyDefaultParagraphFontSize", new TextStyle() { FontName = "Verdana" });
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   document.AppendChildLast(page);
   document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetDefaultParagraphStyle.one"));

Menunjukkan cara menghubungkan hyperlink ke teks.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline
   {
       MaxWidth = 200,
       MaxHeight = 200,
       VerticalOffset = 100,
       HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
       FontColor = Color.Red,
       FontName = "Arial",
       FontSize = 10
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
       IsHyperlink = true,
       HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
       .Append("This is ", textStyleRed)
       .Append("hyperlink", textStyleHyperlink)
       .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Note.Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "AddHyperlink_out.one";
   doc.Save(dataDir);

Constructors

Penulisan teks ()

public TextStyle()
   {
   }

Properties

Default

Dapatkan gaya dengan budaya “en-US”.

public static TextStyle Default
   {
      get;
   }

Nilai Properti

TextStyle

DefaultMsOneNoteTitleDateStyle

Dapatkan gaya default untuk tanggal judul di MS OneNote.

public static TextStyle DefaultMsOneNoteTitleDateStyle
   {
      get;
   }

Nilai Properti

TextStyle

DefaultMsOneNoteTitleTextStyle

Dapatkan gaya default untuk judul teks di MS OneNote.

public static TextStyle DefaultMsOneNoteTitleTextStyle
   {
      get;
   }

Nilai Properti

TextStyle

DefaultMsOneNoteTitleTimeStyle

Dapatkan gaya default untuk waktu judul di MS OneNote.

public static TextStyle DefaultMsOneNoteTitleTimeStyle
   {
      get;
   }

Nilai Properti

TextStyle

HyperlinkAddress

Dapatkan atau menetapkan alamat hyperlink. harus ditetapkan jika nilai sifat Aspose.Note.TextStyle.IsHyperlink adalah benar.

public string HyperlinkAddress
   {
      get;
      set;
   }

Nilai Properti

string

Examples

Menunjukkan cara menghubungkan hyperlink ke teks.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline()
   {
       MaxWidth = 200,
       MaxHeight = 200,
       VerticalOffset = 100,
       HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
       FontColor = Color.Red,
       FontName = "Arial",
       FontSize = 10,
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
       IsHyperlink = true,
       HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
      .Append("This is ", textStyleRed)
      .Append("hyperlink", textStyleHyperlink)
      .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Note.Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "AddHyperlink_out.one";
   doc.Save(dataDir);

IsHidden

Dapatkan atau menetapkan nilai yang menunjukkan apakah gaya teks tersembunyi.

public bool IsHidden
   {
      get;
      set;
   }

Nilai Properti

bool

IsHyperlink

Dapatkan atau menetapkan nilai yang menunjukkan apakah gaya teks adalah hyperlink.

public bool IsHyperlink
   {
      get;
      set;
   }

Nilai Properti

bool

Examples

Menunjukkan cara menghubungkan hyperlink ke teks.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline()
   {
      MaxWidth = 200,
      MaxHeight = 200,
      VerticalOffset = 100,
      HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
      FontColor = Color.Red,
      FontName = "Arial",
      FontSize = 10,
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
      IsHyperlink = true,
      HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
      .Append("This is ", textStyleRed)
      .Append("hyperlink", textStyleHyperlink)
      .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "AddHyperlink_out.one";
   doc.Save(dataDir);

IsMathFormatting

Dapatkan atau menetapkan nilai yang menunjukkan apakah gaya teks adalah format matematika.

public bool IsMathFormatting
   {
      get;
      set;
   }

Nilai Properti

bool

Language

Dapatkan atau menetapkan bahasa teks.

public CultureInfo language { get; set; }

Nilai Properti

CultureInfo

Examples

Menetapkan bahasa bukti untuk teks.

var document = new Document();
   var page = new Page();
   var outline = new Outline();
   var outlineElem = new OutlineElement();
   var text = new RichText() { ParagraphStyle = ParagraphStyle.Default };
   text.Append("United States", new TextStyle() { Language = CultureInfo.GetCultureInfo("en-US") })
       .Append(" Germany", new TextStyle() { Language = CultureInfo.GetCultureInfo("de-DE") })
       .Append(" China", new TextStyle() { Language = CultureInfo.GetCultureInfo("zh-CN") });
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   document.AppendChildLast(page);
   document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

Remarks

Kembali ke System.Globalization.CultureInfo.InvariantKultura jika properti tidak ditetapkan.

Methods

objek yang sama (object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

public override bool Equals(object obj)
   {
   }

Parameters

obj object

dan objeknya.

Returns

bool

Sistem ini adalah Boolean.

Perbedaan ( TextStyle )

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

public bool Equals(TextStyle other)
   {
      return this.IsEqual(other);
   }

Parameters

other TextStyle

dan objeknya.

Returns

bool

Sistem ini adalah Boolean.

Keterangan dari Hashcode()

Ini berfungsi sebagai fungsi hash untuk jenis tersebut.

public override int GetHashCode()
   {
   }

Returns

int

Kegiatan ini dilakukan dengan sistem.Int32.

 Indonesia