Default font

Hi Team,
I am facing an issue while mail-merging. I have 2 sentence, one default fonts and size ex “sentence1” and another with changed font and size ex “sentence2”. And when I am creating the document with mail merge it create the 2nd sentence with applied formatting but for the first sentence it changed to default font size.
~
Sandeep

Hi Sandeep,

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words 16.3.0 generated output document showing the undesired behavior
  • Your expected document showing the desired output. You can create expected document using Microsoft Word.
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,

I have attached the sample application, I am using Aspose.Words 15.3.0.0

Sandeep

Hi Sandeep,

Thanks for your inquiry. I have generated an output document using 16.3.0 and attached it here for your reference. The sentence on first page has font “Calibri” and size “12”. The sentence on second page has font “Arial” and size “9” points. What are your expected values for “font” and “size” on these two pages?

Best regards,

I Have a field in a database table with value-

2.1 SAMPLE FRAMEWORK
GOAL GOAL Sentence goes here.
LEVEL 3 The level 3 management processes, roles, and responsibilities are defined, with on-going tracking and reporting.
LEVEL 4 The value of the level4 management function is understood and managed. Processes drive, and results show, consistent improvement.
Results to the test must be monitored and measured, and action taken when needed.

When I view is webpage the last line font size is 9, But when I create the document using mailmerge the last line changes to 12.

I just wanted to understand why it is changing to font size 12.

I am also attaching the image, how it looks in the webpage and a notepad with html code, since it is converting in page

~

Sandeep

Hi Sandeep,

Thanks for your inquiry. I have attached the following three documents here for your reference

HTMLPage1.html: I have copied your html value in a proper html file. Please open this html with Chrome to observe that the last line has bigger font size.

msw-2016.docx: Above Html was converted to Docx format using MS Word 2016. Here in this file you can observe that the last line has bigger font size.

16.3.0.docx: It was generated using following code

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// builder.MoveToField
builder.InsertHtml(File.ReadAllText(MyDir + "htmlvalue.txt"));
doc.Save(MyDir + @"16.3.0.docx");

So, this seems to be an expected behavior. If we can help you with anything else, please feel free to ask.

Best regards,

Hi,

Further to previous discussion, I tested this on 2 systems. One system is having the default Font size of 16 and another system is having default font size of 18 in MS Word. But in both cases it is generating the last line with font size of 12. Can you tell me why it is still taking 12.

~
Sandeep Kumar

Hi Sandeep,

Thanks for your inquiry. If you want same font size in document, please use the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// builder.MoveToField
builder.InsertHtml(File.ReadAllText(MyDir + "htmlvalue.txt"));
foreach (Run run in doc.GetChildNodes(NodeType.Run, true))
{
    run.Font.Size = 10;
}
doc.Save(MyDir + @"16.3.0.docx");

Hope, this helps.

Best regards,

Hi,

I used the given code, but it sets the font to size to 10. It also set the font size to 10 for other nodes also where font size was provided.

Please suggest.

Regards,
Sandeep Kumar

Hi Sandeep,

Thanks for your inquiry. Please get yourself familiar with Aspose.Words’ Document Object Model. After that you will be able to get the last Row (or any target node) and change the font size of all child Run nodes using Run.Font.Size property.

Best regards,

Hi,

Thanks for providing the link for detailed description. But it is still not clear that why it is displaying the text with font size of 12, when no font size is given and system is not having default font size of 12. I hope you understand my concern.

Regards,
Sandeep Kumar

Hi Sandeep,

Thanks for your inquiry. I have attached the following three documents here for your reference

HTMLPage1.html: I have copied your html value in a proper html file. Please open this html with Chrome to observe that the last line has bigger font size.

msw-2016.docx: Above Html was converted to Docx format using MS Word 2016. Here in this file you can observe that the last line has bigger font size.

16.3.0.docx: It was generated using following code

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// builder.MoveToField
builder.InsertHtml(File.ReadAllText(MyDir + "htmlvalue.txt"));
doc.Save(MyDir + @"16.3.0.docx");

So, this seems to be an expected behavior as Aspose.Words mimics the behavior of MS Word 2016. If we can help you with anything else, please feel free to ask.

Best regards,