Text get cut off from left side when attaching document using builder.insertdocument() function in dot net

Hi Team,

I am attaching one word file, using builder.insertdocument() function. And then generating main document into pdf. While in generated pdf file, text getting cut off from left side.

Can you please help on this.

Attaching dummy project and attachment of word file. As well attached generated pdf file.

ThanksDummy Project 03122020.zip (7.2 MB)

@Pranita.Kasale

Please note that Aspose.Words mimics the behavior of MS Word. If you create a table and insert the content of your document into it using MS Word, you will get the same output.

Please use the following modified code to get the desired output. Hope this helps you.

Aspose.Words.Document wordDoc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(wordDoc);
wordDoc.CompatibilityOptions.GrowAutofit = false;
Aspose.Words.PageSetup pageSet = builder.PageSetup;
pageSet.PaperSize = Aspose.Words.PaperSize.A4;
pageSet.LeftMargin = Aspose.Words.ConvertUtil.InchToPoint(0.5);
pageSet.RightMargin = Aspose.Words.ConvertUtil.InchToPoint(0.5);
pageSet.TopMargin = Aspose.Words.ConvertUtil.InchToPoint(2.5);
pageSet.BottomMargin = Aspose.Words.ConvertUtil.InchToPoint(1);
pageSet.Orientation = Aspose.Words.Orientation.Portrait;
builder.MoveToDocumentEnd();
string genPath = @"C:\AlignmentIssue.docx";
if (System.IO.File.Exists(genPath))
{
    Aspose.Words.Tables.Table table = builder.StartTable();
    builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.None;
    insertTableCell(builder, Aspose.Words.Tables.CellMerge.None, "Product General information", 0, 11, true);
    builder.EndRow();
    insertTableCell(builder, Aspose.Words.Tables.CellMerge.None, " ", 0, 11, true);
    builder.EndRow();


    if (System.IO.File.Exists(genPath))
    {
        Aspose.Words.Document secDoc = new Aspose.Words.Document(genPath);
        secDoc.FirstSection.PageSetup.SectionStart = Aspose.Words.SectionStart.Continuous;
        secDoc.FirstSection.HeadersFooters.LinkToPrevious(true);
        RemoveSectionBreaks(secDoc);
        //modified code start
        foreach (Paragraph paragraph in secDoc.GetChildNodes(NodeType.Paragraph, true))
        {
            paragraph.ParagraphFormat.LeftIndent = 0;
            paragraph.ParagraphFormat.FirstLineIndent = 0;
            paragraph.ParagraphFormat.RightIndent = 0;
        }
        //modified code end
        Aspose.Words.ImportFormatOptions formatOpt = new Aspose.Words.ImportFormatOptions();
        formatOpt.KeepSourceNumbering = true;
        builder.InsertDocument(secDoc, Aspose.Words.ImportFormatMode.KeepSourceFormatting, formatOpt);
    }

    builder.MoveToDocumentEnd();
    builder.EndTable();

    wordDoc.UpdatePageLayout();
    byte[] pdfBytes = null;
    using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
    {
        wordDoc.Save(genPath + "-20.12.pdf", Aspose.Words.SaveFormat.Pdf);
        pdfBytes = stream.ToArray();
    }
}

@tahir.manzoor

Thank you for your reply.

I have applied this and its working at my side.

Thank you so much for your help.