我需要应用缩进并证明段落文本的合理性,因此我已应用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);
请告诉我是否有其他方法可以满足此要求。