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.

Sun May 14, 2023 8:47 pm

Hey guys,

I would like to use something like a default font and default font size for my whole document. I am facing the issue that when I create a new paragraph the whole line is in "Times New Roman". I allready use TextRange but can´t fix my issue.

Code: Select all
...
ParagraphFormat format = paragraph.getFormat();
            format.setLeftIndent(0.0f);
            paragraph.getFormat().getTabs().addTab(21.2f);


            TextRange textRange = paragraph.appendText("\n\n" + Support.integerToRoman(topics) + ".\tKüchen\n");
            textRange.getCharacterFormat().setFontName("OfficinaSansITCPro Book");
            textRange.getCharacterFormat().setFontSize(11.0f);
...

Odosco1992
 
Posts: 2
Joined: Tue Jan 11, 2022 8:35 pm

Mon May 15, 2023 6:16 am

Hi,

Thanks for your feedback.
I did a test with your test code, using the latest Spire.Doc_11.4.2 for Java. The newly added text font settings are correct. Did you use the latest Spire.Doc? If not, you can upgrade and have a test. If the issue still exists, please share us with your full test code, output documents and your font files. So that we work out a solution for you asap. You can send them to us via email (support@e-iceblue.com) or attach them here. Thanks for your assistance.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Mon May 15, 2023 12:57 pm

The code works fine but is it possible to set a default font and a default font size? I don´t want to change the font in every textrange

Odosco1992
 
Posts: 2
Joined: Tue Jan 11, 2022 8:35 pm

Tue May 16, 2023 3:11 am

Hi,

Thank you for your inquiry. Regarding your question about setting default font and font size, kindly note that when adding new text to a paragraph, there is no need to set the font and font size. It will automatically apply the previous textRange's font and font size to the new text.
Please do not hesitate to contact us if you have any further questions or concerns.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc