Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Nov 20, 2024 3:22 pm

Hello,
I have just migrated my solution from version 8 to version 12 of Spire.doc. for .NET.

My IDE shows me an error:
“'CharacterFormat' does not contain a definition for 'font' and no accessible 'font' extension method accepting a first argument of type 'CharacterFormat' has been found.”

After analysis, I realize that the documentation indicates that “font” is indeed present in get/set (attached image “CharacterFormat - Assembly 12.1.5 - API Documentation”), but that the assembly no longer offers it (attached image “CharacterFormat - Assembly 12.1.5 - no Font Getter”)!!!!
Do you have a solution?

Regards

William

ATTIC
 
Posts: 16
Joined: Thu Jun 20, 2019 7:52 am

Thu Nov 21, 2024 7:50 am

Hello,

Thank you for your message.
Regarding the Font property you mentioned, the difference arises due to the distinct frameworks between the .NET version and the .NET Framework version. Due to these framework differences, we adjust some dependencies and API usages accordingly. We apologize for any inconvenience this may have caused you and hope you can understand.
For the use of CharacterFormat in .NET 8.0, please refer to the following code. Additionally, I noticed that the version you updated to is 12.1.5. Currently, our latest version is 12.11.7. Our newer versions are all iterative builds upon previous ones, incorporating more bug fixes than the older versions. I have attached the changelog for each of our versions for your reference. Once again, we apologize and appreciate your understanding.
If you have any further questions or need assistance with migrating to the newer version, please do not hesitate to reach out. We are here to support you through this transition.

Our change logs: https://www.e-iceblue.com/news/spire-doc.html
nuget download: https://www.nuget.org/packages/Spire.Doc/12.11.7

Code: Select all
Document doc = new Document();
Section sec = doc.AddSection();
CharacterFormat characterFormat = new CharacterFormat(doc);
// Set font
characterFormat.FontName = "Times New Roman";
characterFormat.FontSize = 18;
TextRange tr = sec.AddParagraph().AppendText("Hello Spire.Doc");
tr.ApplyCharacterFormat(characterFormat);
doc.SaveToFile("TestNet8_7.0.docx");


Sincerely,
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 455
Joined: Mon Nov 07, 2022 8:10 am

Wed Dec 04, 2024 1:50 pm

Hello,

Yes I installed version 12.1.5, to be in accort with the version in your documentation, before submitting this post.
But I'm using the latest version 12.11.7.

The sample code you've given me doesn't work for me, I need the whole “font” object, not just part of its features.

I've finally found another solution to my problem, without using “CharacterFormat”.

Thanks for your help.

William

ATTIC
 
Posts: 16
Joined: Thu Jun 20, 2019 7:52 am

Thu Dec 05, 2024 2:49 am

Hi,

Thanks your feedback.
I'm glad you've found a solution. If you encounter any issues with Spire in the future, please feel free to contact us anytime.

Sincerely,
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 455
Joined: Mon Nov 07, 2022 8:10 am

Return to Spire.Doc