0

我需要应用缩进并对齐段落文本,因此我为 TextFragment 应用了边距并应用了 justify 属性。但是右侧的文本被移出页面并在右侧显示为修剪过的一些文本。

如果我使用表格单元格并为单元格应用边距并证明单元格文本正在工作但页面大小增加并且性能降低,因此我们不建议使用表格方法。

下面是我的代码片段。

        Document pdfDoc = new Document();
        pdfDoc.PageInfo.Width = 612.0;
        pdfDoc.PageInfo.Height = 792.0;
        pdfDoc.PageInfo.Margin = new MarginInfo();
        pdfDoc.PageInfo.Margin.Left = 72;
        pdfDoc.PageInfo.Margin.Right = 72;
        pdfDoc.PageInfo.Margin.Top = 72;
        pdfDoc.PageInfo.Margin.Bottom = 72;

        Page pdfPage = pdfDoc.Pages.Add();
        pdfPage.PageInfo.Width = 612.0;
        pdfPage.PageInfo.Height = 792.0;
        pdfPage.PageInfo.Margin = new MarginInfo();
        pdfPage.PageInfo.Margin.Left = 72;
        pdfPage.PageInfo.Margin.Right = 72;
        pdfPage.PageInfo.Margin.Top = 72;
        pdfPage.PageInfo.Margin.Bottom = 72;

        TextFragment textfragment = new TextFragment("This line for verify the indent");
        textfragment.TextState.FontSize = 12;
        textfragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");
        textfragment.TextState.LineSpacing = 15;
        pdfPage.Paragraphs.Add(textfragment);

        textfragment = new TextFragment("TextFragment with Justify : This AGREEMENT AND PLAN OF MERGER (this \"Agreement\") is made and entered into as of ______ __, ____, by and among ___________________, a Delaware corporation (\"Parent\"),___________________, a Delaware corporation and a wholly owned subsidiary of Parent (\"MergerSub\"), and ___________________, a Delaware corporation (the \"Company\").");
        textfragment.TextState.HorizontalAlignment = HorizontalAlignment.Justify;
        textfragment.TextState.FontSize = 12;
        textfragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");
        textfragment.TextState.LineSpacing = 15;
        //for ss_indent I have given 10f left indent into text fragment.
        textfragment.Margin = new MarginInfo(10f, 0f, 0f, 0f);
        pdfPage.Paragraphs.Add(textfragment);

        textfragment = new TextFragment("TextFragment without Justify : This AGREEMENT AND PLAN OF MERGER (this \"Agreement\") is made and entered into as of ______ __, ____, by and among ___________________, a Delaware corporation (\"Parent\"),___________________, a Delaware corporation and a wholly owned subsidiary of Parent (\"MergerSub\"), and ___________________, a Delaware corporation (the \"Company\").");
        textfragment.TextState.FontSize = 12;
        textfragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");
        textfragment.TextState.LineSpacing = 15;
        //for ss_indent I have given 10f left indent into text fragment.
        textfragment.Margin = new MarginInfo(10f, 0f, 0f, 0f);
        pdfPage.Paragraphs.Add(textfragment);

如果有其他方法可以满足此要求,请建议我。

代码的输出

4

0 回答 0