question

Jackson1990-7147 avatar image
0 Votes"
Jackson1990-7147 asked Castorix31 answered

Issue to have bold effect

Hi,
How to correct the line below, to have Bold effect?

RunProperties runProperties = run.AppendChild(new RunProperties(new Bold { Val = BoldValues.Single }));

dotnet-csharpdotnet-standard
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered

Based on MSDN sample, this creates a .docx with a bold text =>

 string sFilePath = "Test.docx";
 using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(sFilePath, WordprocessingDocumentType.Document))
 {
     // Add a main document part. 
     MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
    
     // Create the document structure and add some text.
     mainPart.Document = new Document();
     Body body = mainPart.Document.AppendChild(new Body());
     Paragraph para = body.AppendChild(new Paragraph());
     Run run = para.AppendChild(new Run());
    
     run.Append(new Text("This is a bold text"));
     RunProperties runProperties = new RunProperties();
     runProperties.Append(new Bold());
     run.RunProperties = runProperties;
 }
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.