Justification getting applied on Stamp

We are applying justification on the document generated from SSRS using the below code:

       Aspose.Words.Document doc = new Aspose.Words.Document(@"E:\Input_Document.docx");
        Aspose.Words.NodeCollection paragraphTest12 = doc.GetChildNodes(Aspose.Words.NodeType.Paragraph, true);
        bool flag1 = false;
        foreach (Aspose.Words.Paragraph para in paragraphTest12)
        {
            if (para.ToString(Aspose.Words.SaveFormat.Text).StartsWith("Evaluation Only. Created with Aspose.Words."))
                continue;

            if (para.Runs.Count > 0 && para.Runs[0].Font.Bold == true)
                flag1 = true;

            if (flag1)
                para.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Justify;
        }
      doc.Save(@"E:\Output_Document.pdf",Aspose.Words.SaveFormat.Pdf);

But on using the above code, justification is getting applied for stamp as well. could you please let us know if we are missing something. Attached the input document and the output document.Documents.zip (421.2 KB)

@guruchandran,

Thanks for your inquiry. In your code, you are setting the alignment of paragraphs after a paragraph that has bold font formatting. In this case, after the following text, all paragraphs in the document have alignment as justify.

Subject: HERON HUNTER; IMO 9440801 - Dispensation - Anenometer

Could you please share what exact you want to achieve using Aspose.Words? We will then provide you more information about your query along with code.

@tahir.manzoor
Thanks for your response.
It is pretty simple. We don’t want to apply justification on the Stamp. In the output_document under stamp the name “Margaret Ansumana” is justified which we need to avoid it.

@guruchandran,

Thanks for your inquiry. Please use the following code to get the desired output. Please check the last if condition in the foreach loop.

Document doc = new Document(MyDir + @"Input_Document.docx");

Aspose.Words.NodeCollection paragraphTest12 = doc.GetChildNodes(Aspose.Words.NodeType.Paragraph, true);
bool flag1 = false;
foreach (Aspose.Words.Paragraph para in paragraphTest12)
{
    if (para.ToString(Aspose.Words.SaveFormat.Text).StartsWith("Evaluation Only. Created with Aspose.Words."))
        continue;

    if (para.Runs.Count > 0 && para.Runs[0].Font.Bold == true)
        flag1 = true;

    if (flag1 && para.GetChildNodes(NodeType.Shape, true).Count > 1)
    {
        para.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Justify;
    }

}

doc.Save(MyDir + "output.pdf");