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 Jan 03, 2024 10:04 am

Hi,
Is there option (SpireDoc for java 11.7.0) to set default line spacing for new added/imported from HTML paragraphs, like in MS Word.
word-change-default-line-spacing.png

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 68
Joined: Sun Jan 08, 2023 2:36 pm

Thu Jan 04, 2024 2:17 am

Hello,

Thank you for your inquiry.
To meet your requirements, please refer to the following code snippet for implementation:
Code: Select all
// Create a new Document object
Document document = new Document();
// Add a new Section to the document
Section section = document.addSection();
// Create a ParagraphStyle and set its formatting properties
ParagraphStyle paragraphStyle = document.addParagraphStyle("defaultName");
paragraphStyle.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Left);
paragraphStyle.getParagraphFormat().setOutlineLevel(OutlineLevel.Body);
paragraphStyle.getParagraphFormat().setFirstLineIndentChars(2);
paragraphStyle.getParagraphFormat().setLeftIndent(0);
paragraphStyle.getParagraphFormat().setLineSpacing(18);
// Get the first paragraph in the section and apply the default style to it, then append HTML content to it
Paragraph paragraph = section.getParagraphs().get(0);
paragraph.applyStyle("defaultName");
paragraph.appendHTML(htmls);
// Add a new paragraph to the section
paragraph = section.addParagraph();
paragraph.applyStyle("defaultName");
paragraph.appendHTML(htmls);
// Save the document to a file with the specified name and format
document.saveToFile("result.docx", FileFormat.Docx_2013);

If you have any further questions or need additional assistance, please don't hesitate to reach out to us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Jan 04, 2024 10:29 am

Hi Anika,
Thanks for quick answer.
As I understood there is no option change default style for new added paragraphs.
We should to apply style to each paragraph we adding to document.

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 68
Joined: Sun Jan 08, 2023 2:36 pm

Fri Jan 05, 2024 2:15 am

Hello,

Thank you for your feedback.
Indeed, currently our product does not have an option to modify the default style for newly added paragraphs. I consulted with our development team, and I'm glad to inform you that this feature has been added to our upgrade list with the reference number SPIREDOC-10180. Our development team will investigate and implement it accordingly. Once it's implemented, we will notify you promptly.
In the meantime, as a workaround, you can create a Word document and set the desired default styles. Then, you can apply the default styles to your document using our cloneDefaultStyleTo() method. Below is an example code snippet:
Code: Select all
Document document1 = new Document();
document1.loadFromFile("defaultStyle.docx");
Document document = new Document();
document.loadFromFile("input.docx");
document1.cloneDefaultStyleTo(document);
...

This will help you apply the desired default styles until the requested feature becomes available.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Feb 14, 2024 12:27 pm

Hello,

do you have any new update regarding this feature?

thank you

adi.zahi
 
Posts: 7
Joined: Tue Jan 30, 2024 10:12 am

Thu Feb 15, 2024 4:50 am

Hello,

Thanks for following up.
I am sorry to tell that there is no significant progress so far. Our Dev team would keep looking into it. Once it is fixed, I will let you know asap. Thanks for your patience.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Thu Dec 26, 2024 7:15 am

Hi, do we have any progress with this issue?

andrei.chorin
 
Posts: 68
Joined: Sun Jan 08, 2023 2:36 pm

Thu Dec 26, 2024 8:01 am

Hello,

Thank you for your inquiry again.
This feature is really complicated and the development has not yet completed the implementation. We will notify you as soon as this feature is implemented.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3008
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc