We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to change the font size/ font name of the above result ?

Thread ID:

Created:

Updated:

Platform:

Replies:

126383 Oct 12,2016 08:50 AM Apr 23,2018 03:48 AM ASP.NET MVC 7
loading
Tags: DocIO
New Tester
Asked On October 12, 2016 08:50 AM

       IWParagraph header = section.HeadersFooters.Header.AddParagraph();
                            header.AppendText("Site: ");
                            header.AppendField("CurrentPageNumber", FieldType.FieldPage);
                            header.AppendText("/");
                            header.AppendField("TotalNumberOfPages", FieldType.FieldNumPages);

How to change the font size/ font name of the above result, the result text is "Site 1/12"

Vijay Ramachandran [Syncfusion]
Replied On October 13, 2016 03:05 AM

Hi Customer,

Thank you for using Syncfusion products.

You can set font name and font size for the text using the text range character format property. Kindly use the following code snippets instead of the given code snippet to set font name and font size. In this code snippet the highlighted code set the font name and size for the text.
 
      IWParagraph header = section.HeadersFooters.Header.AddParagraph(); 
      IWTextRange textRange = header.AppendText("Site: "); 
      //Set font name and font size for the text ranage 
      textRange.CharacterFormat.FontName = "Calibri"; 
      textRange.CharacterFormat.FontSize = 12; 
      IWField field = header.AppendField("CurrentPageNumber", FieldType.FieldPage); 
      field.CharacterFormat.FontName = "Calibri"; 
      field.CharacterFormat.FontSize = 12; 
      textRange = header.AppendText("/"); 
      textRange.CharacterFormat.FontName = "Calibri"; 
      textRange.CharacterFormat.FontSize = 12; 
      field = header.AppendField("TotalNumberOfPages", FieldType.FieldNumPages); 
      field.CharacterFormat.FontName = "Calibri"; 
      field.CharacterFormat.FontSize = 12; 

Please refer the following UG documentation link for more details:
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text

Let us know if you have any concern.

Regards,
Vijay R


New Tester
Replied On October 13, 2016 03:44 AM

I still have the same font and font size

New Tester
Replied On October 13, 2016 03:52 AM

Sorry, you are right.

Pon Geetha A J [Syncfusion]
Replied On October 13, 2016 05:02 AM

Hi Customer, 
  
We are glad that our solution worked. 
  
Regards, 
Geetha 


Jochen Albrecht
Replied On April 19, 2018 10:52 AM

With version 16.1.0.24:

IWField field = paragraph2.AppendField("Page", FieldType.FieldPage);
field.CharacterFormat.FontSize = 6;

the fontsize within IWField will not change...

With IWTextRange it is ok.

IWTextRange textrange = paragraph0.AppendText("TEST");
textrange.CharacterFormat.FontSize = 6;

Mohanaselvam  Jothi [Syncfusion]
Replied On April 20, 2018 08:04 AM

Hi Jochen,

Thank you for your update.

From v16.1.0.24, the entire field code is included in Document Object Model (DOM). Hence the adding a field will automatically include below elements in DOM,

   1. WField -- represents the starting of Field.
   2. ParagraphItem – represents the Field code.
   3. WFieldMark –represents the Field separator.
   4. ParagraphItem – represents the Field result.
   5. WFieldMark – represents the end of Field

Please refer the below UG documentation link to know about migration changes in DocIO:
https://help.syncfusion.com/file-formats/release-notes/migratingtov16.1.0.24

To achieve your requirement, we suggest you to set font size for Field and its paragraph items.
Please refer the below code snippets to achieve your requirement using DocIO:
 
IWField field = paragraph2.AppendField("Page", FieldType.FieldPage); 
 
IEntity entity = field; 
//Iterates to sibling items until Field End 
while (entity.NextSibling != null) 
{     
    if (entity is WTextRange) 
        //Sets character format for text ranges. 
        (entity as WTextRange).CharacterFormat.FontSize = 6;     
    else if ((entity is WFieldMark) && (entity as WFieldMark).Type == FieldMarkType.FieldEnd) 
        break; 
    entity = entity.NextSibling; 
} 



Please let me know if you have any other questions.

Regards,
Mohanaselvam J
 


Jochen Albrecht
Replied On April 23, 2018 03:48 AM

Hi,

thanks. That´s the way...

Regards,
Jochen

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;