Indentation Issue

We are having Paragraph with tags in between in Template which is properly indented. But when we insert data into tag Indentation Changes.

image.png (14.3 KB)

Code used:
builder.ParagraphFormat.LeftIndent = 0;
builder.ParagraphFormat.FirstLineIndent = 0;

Since we use above Indentation to only write data inside tags and other text are from template which are not changing anything in code,Though i get indentation issue after entering values into tag.

@NanthiniSenthil123 Please attach the source code, template and output document here, we will check the issue and provide you with additional information.

Attached Source code and Template and output File for your reference.
Source code:

string ParaData = string.Empty;
if (WriteSeqNoCount[count].count == 1)
    ParaData = WriteSeqNoCount[count].Items[0].Column1;
else
{
    for (int w = 0; w < WriteSeqNoCount[count].Items.Count; w++)
    {
        ParaData = ParaData + " " + WriteSeqNoCount[count].Items[w].Column1;
    }
}
if (!string.IsNullOrEmpty(ParaData))
    builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.ParagraphFormat.LeftIndent = 0;
builder.ParagraphFormat.FirstLineIndent = 0;

Template for Indentation.docx (15.7 KB)
Output file for indentation issue.docx (15.4 KB)

@NanthiniSenthil123 I did not see in your “Output file for indentation issue.docx” any issue specified in the initial post in “image.png”.
In general, a paragraph marked ““A S” includes all items, $$$Tag START{Pre_Test}Tag…” looks exactly like the image in the screenshot with “Expected Output” caption. Please explain what kind of formatting you expect under number 1 or 2. Or is it some other formatting?

We can see in Expected output file the para in indended after numeric bullet,but in output i get the value is displaying under the numeric bullet which is to be increase indended.

See Second line for Each para for the difference.Expected is Second line to be indended from nuemeric bullet

My Output:

  1. Text for Para1 is here which is to indented,testing this and adding to your reference here we can see second line starts from numeric bullets.

Expected Output:

  1. Text for Para1 is here which is to indented,testing this and adding to your reference here we
    can see second line starts straight under First line Start not under Numeric bullets.

@NanthiniSenthil123 You don’t need to reset LeftIndent.
The document in which the expected and problematic paragraphs.
TestDoc.docx (15.1 KB)

Document doc = new Document("TestDoc.docx");
doc.FirstSection.Body.Paragraphs[3].ParagraphFormat.LeftIndent = ConvertUtilCore.TwipToPoint(360);
doc.Save("TestDocOut.docx");

Outpu docuement.
TestDocOut.docx (10.6 KB)

Hi,

I am trying to indend only few lines in Para where tag should remain o indend as below

$$$Tag START{SL:

NO TEXT FOUND ON DATABASE

NO TEXT FOUND ON DATABASE

SL ES:

CARD DFTCE
HHTEXT PPR EX ING NO>17
PLANTS
}Tag END$$$

but what i get is i have attached as Document,Can you help me to indend few lines in para where the end tag should not be disturbed
Indendation issue in last line(ASPOSE).docx (14.7 KB)

@NanthiniSenthil123 I am afraid it is not possible to indent only separate lines of paragraphs. Indent can be specified only to a whole paragraph or to the first line of the paragraph. So to achieve what you need you should put the lines into separate paragraphs.

I got it,My Expectation is same i am trying to indent all three lines as attached before.but tag shoud remain same, but when i try to indent tag is moving as well,Please refer document.

Expected Output:

SL ES:

CARD DFTCE
HHTEXT PPR EX ING NO>17
PLANTS

}Tag END$$$

Note:When i Add line break between Tag and Data indentation Works Good but Expectation is Tag should be without Line break

Indendation issue in last line(ASPOSE).docx (14.7 KB)

@NanthiniSenthil123 As I mentioned tag end should be in a separate paragraph to get the desired output. Please see the following screenshot:

Thank you That helps but when i add below line for paragraphbreak I am getting linebreak as below
builder.InsertBreak(BreakType.ParagraphBreak);

Output:
CARD DFTCE
HHTEXT PPR EX ING NO>17
PLANTS

}Tag END$$$

Help me to insert paragrpahbreak without line break before end tag

@NanthiniSenthil123 Most likely there is a soft line break after "PLANTS" string that produces an additional line break. You can trim it to avoid the problem. If the problem still persist, please provide sample code that will allow us to reproduce the problem, we will check it and provide you more information.

We have already used trim for data,Please refer below code which we use to write para

string ParaHeading="Text";
builder.ParagraphFormat.LeftIndent = 30;
builder.ParagraphFormat.FirstLineIndent = 30;
if (NextTypeNo == 7)
{
    builder.InsertBreak(BreakType.ParagraphBreak);
    builder.ParagraphFormat.LeftIndent = 0;
    builder.ParagraphFormat.FirstLineIndent = 0;
}
builder.Font.Bold = false;
builder.Write(ParaHeading.Trim());

@NanthiniSenthil123 Please try explicitly trimming soft line break character at the end of the string using code like this:

text.TrimEnd(ControlChar.LineBreakChar);

Still I am getting Linebreak
SLE:

CARD DFTCE
HHTEXT PPR EX ING NO>17
PLANTS

}Tag END$$$

Code used:

builder.ParagraphFormat.LeftIndent = 30;
builder.ParagraphFormat.FirstLineIndent = 30;
if (NextTypeNo == 7)
{

    builder.InsertBreak(BreakType.ParagraphBreak);
    ParaHeading.TrimEnd(ControlChar.LineBreakChar);
    builder.ParagraphFormat.LeftIndent = 0;
    builder.ParagraphFormat.FirstLineIndent = 0;

}

@NanthiniSenthil123 Could you please create a simple code example that will allow us to reproduce the problem I have checked with the following code and the output looks correct:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("SL ES:");

builder.ParagraphFormat.LeftIndent = 20;
builder.Writeln("CARD DFTCE\vHHTEXT  PPR EX ING NO > 17\vPLANTS");

builder.ParagraphFormat.LeftIndent = 0;
builder.Write("}Tag END$$$");

doc.Save(@"C:\Temp\out.docx");

out.docx (7.1 KB)

Let me check above issue,Meanwhile i have other indendation issue in bulleted Paragraphs .

Currently we don’t use any code for indendation.

@NanthiniSenthil123 There are two ways to achieve what you need. You should either specify the second paragraph indent to line up the text in the list item and in the regular paragraph (if list item and the Text2 are separate paragraphs) or use soft line break instead of paragraph break between Text1 and Text2. Please see the attached sample document: example.docx (13.3 KB)

Can you help me with sample code, We dont use Paragraphbreak in code . Test1 and Test2 are same paragraph under first bullet .Here i attached sample code we used.

string ParaData = string.Empty;
if (WriteSeqNoCount[count].count == 1)
    ParaData = WriteSeqNoCount[count].Items[0].Column1;
else
{
    for (int w = 0; w < WriteSeqNoCount[count].Items.Count; w++)
    {
        ParaData = ParaData + " " + WriteSeqNoCount[count].Items[w].Column1;
    }
}
if (!string.IsNullOrEmpty(ParaData))
    WriteInDocument(builder, ParaData, false);

Ouput:

image.png (9.4 KB)