Remove bullet or number from middle of the paragraph

Hi,

I am updating an existing document to find and replace a word. I am finding a word and replacing it with paragraphs with different data. Among those paragraphs, I need to add a hyperlink without numbering(not sure if it can have numbering, bullet, or neither). Writing the sample code inside the replacing method after creating the builder with the replaced node,

for(int i=0;i<array.length;i++){
     builder.inserthtml(array[i]);
     builder.inserthyperlink("NEXT",bookmark, true)
}

this hyperlink should be without any list format and in the center. But if I remove the numbering or bullet if any from the hyperlink then the content after the hyperlink should retain the same. Please help me with it

Thank you

@Gptrnt Could you please attach your sample input, output and expected output documents here for testing along with code that will allow us to reproduce the problem? We will check the issue and provide you more information.

Hi Alexey,
I have figured out the solution. Thanks for you quick reply.

Thank you

1 Like

Hi,

I have one more issue with numbering. While updating the document I will add a page like a cover page(like some title in the middle with big font) followed by more than one bank page in the middle of the pages. Normal pages contain title (in heading1 style) and content(normal style). if the heading style has set some numbering option then the title will come with numbering as expected. But if the title is just after the blank page then the numbering font size is bigger than the heading font size(taking the cover page heading font size). I am attaching the output document
test.docx (17.8 KB).

I can’t change any formatting on the blank page only on the normal page or cover page can make the change. Please help me to figure out the solution.
Thank you

@Gptrnt The problem is that part of formatting in your document is applied via style and part of formatting is applied explicitly. For example lets consider the following paragraph:


This paragraph internally represented as the following:

<w:p w14:paraId="4831454E" w14:textId="77777777" w:rsidR="00C42097" w:rsidRDefault="00000000" w:rsidP="00B33E26">
	<w:pPr>
		<w:pStyle w:val="Heading2"/>
		<w:keepNext w:val="0"/>
		<w:keepLines w:val="0"/>
		<w:tabs>
			<w:tab w:val="left" w:pos="1417"/>
		</w:tabs>
		<w:spacing w:before="240"/>
		<w:ind w:left="0" w:firstLine="0"/>
		<w:jc w:val="center"/>
		<w:rPr>
			<w:rFonts w:eastAsia="Times New Roman" w:cs="Times New Roman"/>
			<w:u w:val="single"/>
		</w:rPr>
	</w:pPr>
	<w:r>
		<w:rPr>
			<w:rFonts w:eastAsia="Times New Roman" w:cs="Times New Roman"/>
		</w:rPr>
		<w:br w:type="page"/>
	</w:r>
	<w:r>
		<w:rPr>
			<w:rFonts w:eastAsia="Times New Roman" w:cs="Times New Roman"/>
			<w:sz w:val="66"/>
		</w:rPr>
		<w:lastRenderedPageBreak/>
		<w:t>Attachment : AA9196122</w:t>
	</w:r>
</w:p>

As you can see Heading2 style is applied to the whole paragraph. But font size of the content is applied explicitly in rPr: <w:sz w:val="66"/>. Size of the list item label is taken from paragraph break font formatting (see Paragraph.ParagraphBreakFont property). Since it’s size is not explicitly specified, labels uses font specified in the applied style. Here is where the difference in font size comes from.

Hi Alexey,

Can you give me a way to fix it? I am not sure how I will fix it.

Thank you

@Gptrnt If it is required to have the same font size for list item label and paragraph content, you should specify the same font in the Paragraph.ParagraphBreakFont and run’s font. For example see the following code:

Document doc = new Document();
Paragraph p = doc.getFirstSection().getBody().getFirstParagraph();
// Apply style to the paragraph.
p.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
// Add some text to the paragraph with explicit formatting.
Run r = new Run(doc, "Some Text");
r.getFont().setSize(33);
p.appendChild(r);
// Apply numbering.
p.getListFormat().applyNumberDefault();
// If save the document now, the list item label will not have 33 font size
// It will inherit font size from the applied style.
doc.save("C:\\Temp\\out_different_font_size.docx");
// Now change the list item font size.
p.getParagraphBreakFont().setSize(33);
doc.save("C:\\Temp\\out_same_font_size.docx");

out_different_font_size.docx (8.1 KB)
out_same_font_size.docx (8.1 KB)

Hi Alexey,

I am attaching my sample code Main.zip (3.6 KB), input file input.docx (20.9 KB) and output file output.docx (16.7 KB). As you can see, the first attachment numbering is a small font and the next item title picks a bigger font than the content. Please suggest where I can update the code to maintain the numbering with the same font.

Thank you

@Gptrnt Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side with the provided code. Here is the output produced on my side:
out.docx (18.8 KB)
out.pdf (69.0 KB)

As you can see all list item labels have the same font as the items’ text.