From ddf46eb30cff91de401b70f5a6053be2271b96e0 Mon Sep 17 00:00:00 2001 From: GOPINATHSF4767 Date: Tue, 25 Aug 2026 10:12:03 +0530 Subject: [PATCH] Added sample --- .../Apply-Custom-Font-For-TOC-Headings.sln | 25 ++++++ .../Apply-Custom-Font-For-TOC-Headings.csproj | 21 +++++ .../Output/.gitkeep | 1 + .../Output/Output.docx | Bin 0 -> 6135 bytes .../Program.cs | 84 ++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings.sln create mode 100644 Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Apply-Custom-Font-For-TOC-Headings.csproj create mode 100644 Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/.gitkeep create mode 100644 Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/Output.docx create mode 100644 Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Program.cs diff --git a/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings.sln b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings.sln new file mode 100644 index 000000000..e32248a86 --- /dev/null +++ b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.37614.0 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apply-Custom-Font-For-TOC-Headings", "Apply-Custom-Font-For-TOC-Headings\Apply-Custom-Font-For-TOC-Headings.csproj", "{000D8166-FF6B-E115-AEE0-A0A05404C8D8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {000D8166-FF6B-E115-AEE0-A0A05404C8D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {000D8166-FF6B-E115-AEE0-A0A05404C8D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {000D8166-FF6B-E115-AEE0-A0A05404C8D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {000D8166-FF6B-E115-AEE0-A0A05404C8D8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {60A98D90-ADE4-44B7-B094-64DB371D3B67} + EndGlobalSection +EndGlobal diff --git a/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Apply-Custom-Font-For-TOC-Headings.csproj b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Apply-Custom-Font-For-TOC-Headings.csproj new file mode 100644 index 000000000..0576fec6a --- /dev/null +++ b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Apply-Custom-Font-For-TOC-Headings.csproj @@ -0,0 +1,21 @@ + + + + Exe + net8.0 + Apply_Custom_Font_For_TOC_Headings + + + + + Always + + + + + + + + + + diff --git a/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/.gitkeep b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/Output.docx b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Output/Output.docx new file mode 100644 index 0000000000000000000000000000000000000000..a02f627984dcc0f30e0af8f0fb2ddbd317a80595 GIT binary patch literal 6135 zcmaJ_1ymIM-d0CrWM7q1BQ>7ab5s*;&Ti^TL z>%H9f`)1CWIcH{`|D1W|_dLJQPz9n80|0;rfW$mIPFDaO z5TuJG&an1BW`To30=U0j@Ru+$4QM3ACuPt9*+n|ynMeqrH9Y8<+_77HidczYTObE2BNifRSC zqn~Y})|_G?J#X>TLY-f)BgAtZONRE6*|&IJHXNS#Vn~%-AuVwydK&JOS1V2p7MjGg zqK(X*(UvSyRc2bBBkNb(>|?WPRfO)g20!=SZL%a^!?so35kxE6aCA!5lrk!PB%yS! z;6>q_i7%wD(n`SebU~YF(`9=Z(0ER~{$PgYtjy&r3u*?}z6D{nWvhWM-PwrR7Kd}q zP!V=!L{5ye<+*D9kvycp;E06i=QP{f8=XPFQsDvdnjf}6q`@gGHn;+j0$4vxRwIl% zNO;U2oYfR6$p{Tx6(tbq3IA>)k~G{ylXllMed`P%iw&aBq9g6i#@oaX>GC(9>eCs# zG*X`#mC=xkEeQKU&NOYxW(y`ikEl|3A@njlP9`I!PHt9jAs0m+{-M4dd2X3LtHv^i z4kxQNJDi?3Cvle7j#Xbpq@I$OEp|@W^84yhl2KxxhAlWMkHE|I#2nj^F=%}q5VDB9 z6o3W_Rrs)9i{t?lieP~!F;bEI@TvTD0xpcQ?s<R2gY3ker@}tyYao+`3-e+BlB@ zt~V7nUfhuNaO>Z^TzelVUWarp zy|#8n!SOO7(pY{t$JDsEhY_E?z~{W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42mZ-y9b6LlgJD>64S%EP4vR~dALo#6{gI|BXHDTK=Q3?+kV z-=lp7o-eL|FP4!`K(#+fKdf+fQ-dW1fQT}0Mqj3dSJu}xAyNd zHy)r(Ky~ki*Of)R&tb-op;KLFgIoRL#KR=4yD)h6zH*@HLk4zlEg9x;?obJ$Rr(z9 zo*hJC`rphX=FwfKA>=@X2qz*0Ge)vbj&6wgps9|xvlZ0jw<_vVq(Qwr_=q_1h7mS$ z;LE7D0vaY!$=-ic2AlhGOw_?`EV`4LkX07Y%IvTneDdNyxw~qxSutI;hH-gSN2uXi zFqUr1VMd`)uD<;k)4S7vS)W`LU z5<02IxTC-b$#VyOb>(Z;LSvBK3h~7g&0m(T)XVGlAH;7If53pk|S2(Q%q_)6BexkY|9xiR&!;ku?@J@g7Hgv460c&Anfsa3l2IdAEJt&BP zUhcmlcNpj6%(5Dg`(PH4e{x>DPytKjm9|FD@Adgsp$G@Kxg$7J=I$cPA$zmcMbDk|FVhcFPkB*M#zes`IG F{{aKX$vyx8 literal 0 HcmV?d00001 diff --git a/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Program.cs b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Program.cs new file mode 100644 index 000000000..0faba920e --- /dev/null +++ b/Table-Of-Contents/Apply-Custom-Font-For-TOC-Headings/.NET/Apply-Custom-Font-For-TOC-Headings/Program.cs @@ -0,0 +1,84 @@ +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; +using System.IO; + +namespace Apply_Custom_Font_For_TOC_Headings +{ + class Program + { + static void Main(string[] args) + { + //Creates a new Word document + using (WordDocument document = new WordDocument()) + { + //Adds the section into the Word document. + IWSection section = document.AddSection(); + string paraText = "AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."; + //Adds the paragraph into the created section. + IWParagraph paragraph = section.AddParagraph(); + //Appends the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries. + paragraph.AppendTOC(1, 3); + //Adds the section into the Word document. + section = document.AddSection(); + //Adds the paragraph into the created section. + paragraph = section.AddParagraph(); + //Adds the text for the headings. + IWTextRange textRange = paragraph.AppendText("First Chapter"); + //Apply character formatong to the text ranges. + textRange.CharacterFormat.FontName = "Calibri"; + textRange.CharacterFormat.FontSize = 15; + //Sets a built-in heading style. + paragraph.ApplyStyle(BuiltinStyle.Heading1); + //Gets the paragrapg style. + IWParagraphStyle style = paragraph.GetStyle(); + style.CharacterFormat.ClearFormatting(); + //Adds the text into the paragraph. + IWParagraph firstParagraph = section.AddParagraph(); + IWTextRange text = firstParagraph.AppendText(paraText); + //Sets font name and size for the paragraphs. + text.CharacterFormat.FontName = "Calibri"; + text.CharacterFormat.FontSize = 12; + //Adds the section into the Word document. + section = document.AddSection(); + //Adds the paragraph into the created section. + paragraph = section.AddParagraph(); + //Adds the text for the headings. + textRange = paragraph.AppendText("Second Chapter"); + //Apply character formatong to the text ranges. + textRange.CharacterFormat.FontName = "Verdana"; + textRange.CharacterFormat.FontSize = 15; + //Sets a built-in heading style. + paragraph.ApplyStyle(BuiltinStyle.Heading2); + style = paragraph.GetStyle(); + style.CharacterFormat.ClearFormatting(); + //Adds the text into the paragraph. + firstParagraph = section.AddParagraph(); + text = firstParagraph.AppendText(paraText); + text.CharacterFormat.FontName = "Verdana"; + text.CharacterFormat.FontSize = 12; + //Adds the section into the Word document. + section = document.AddSection(); + //Adds the paragraph into the created section. + paragraph = section.AddParagraph(); + //Adds the text into the headings. + textRange = paragraph.AppendText("Third Chapter"); + //Apply character formatong to the text ranges. + textRange.CharacterFormat.FontName = "Calibri"; + textRange.CharacterFormat.FontSize = 15; + //Sets a built-in heading style. + paragraph.ApplyStyle(BuiltinStyle.Heading3); + style = paragraph.GetStyle(); + style.CharacterFormat.ClearFormatting(); + //Adds the text into the paragraph. + firstParagraph = section.AddParagraph(); + text = firstParagraph.AppendText(paraText); + text.CharacterFormat.FontName = "Calibri"; + text.CharacterFormat.FontSize = 12; + //Updates the table of contents. + document.UpdateTableOfContents(); + //Save and close the Word document. + document.Save(Path.GetFullPath("../../../Output/Output.docx")); + } + } + } +}