C# PDF4Net:段落最后一行的文本对齐

C# PDF4Net:段落最后一行的文本对齐,c#,pdf,C#,Pdf,我正在使用O2 Solutions提供的名为PDF4NET的dll 我有如下代码: PDFTextFormatOptions tfo new PDFTextFormatOptions; tfo.Align = TextAlign.TopJustified; tfo.KeepWhiteSpaces = True; tfo.LineSpacing = 2; string ltrtxt = "IMPORTANT: This is just some text representing a parag

我正在使用O2 Solutions提供的名为PDF4NET的dll

我有如下代码:

PDFTextFormatOptions tfo new PDFTextFormatOptions;
tfo.Align = TextAlign.TopJustified;

tfo.KeepWhiteSpaces = True;
tfo.LineSpacing = 2;
string ltrtxt = "IMPORTANT: This is just some text representing a paragraph. This is just some extra text to make the paragraph longer.";
pdfPage.Canvas.DrawHTMLTextBox(ltrtxt, 
    PDFReportsConfig.Arial_HTML11, 
    Nothing, 
    PDFReportsConfig.BlackBrush, 
    y, x, 3, 2, tfo);
IMPORTANT: This is just some  text 
representing a paragraph.  This is 
just some  extra text  to make the 
paragraph                  longer.
ltrtxt += vbCrLf
ltrtxt += vbCr
ltrtxt += vbLf
这将创建一个如下所示的段落:

PDFTextFormatOptions tfo new PDFTextFormatOptions;
tfo.Align = TextAlign.TopJustified;

tfo.KeepWhiteSpaces = True;
tfo.LineSpacing = 2;
string ltrtxt = "IMPORTANT: This is just some text representing a paragraph. This is just some extra text to make the paragraph longer.";
pdfPage.Canvas.DrawHTMLTextBox(ltrtxt, 
    PDFReportsConfig.Arial_HTML11, 
    Nothing, 
    PDFReportsConfig.BlackBrush, 
    y, x, 3, 2, tfo);
IMPORTANT: This is just some  text 
representing a paragraph.  This is 
just some  extra text  to make the 
paragraph                  longer.
ltrtxt += vbCrLf
ltrtxt += vbCr
ltrtxt += vbLf
也就是说,该段是左右对齐的

IMPORTANT: This is just some  text 
representing a paragraph.  This is 
just some  extra text  to make the 
paragraph longer.
我希望保持对齐,但我也希望最后一行不对齐

IMPORTANT: This is just some  text 
representing a paragraph.  This is 
just some  extra text  to make the 
paragraph longer.
如何使段落完全对齐,但允许最后一行左对齐

当我在谷歌上搜索“PDFTextFormatOptions”(带引号)时,我得到两个结果

我继承了这个项目,所以我不知道原始文档在哪里

[编辑] 我试图在字符串的末尾添加换行符,但没有效果。我是这样加的:

PDFTextFormatOptions tfo new PDFTextFormatOptions;
tfo.Align = TextAlign.TopJustified;

tfo.KeepWhiteSpaces = True;
tfo.LineSpacing = 2;
string ltrtxt = "IMPORTANT: This is just some text representing a paragraph. This is just some extra text to make the paragraph longer.";
pdfPage.Canvas.DrawHTMLTextBox(ltrtxt, 
    PDFReportsConfig.Arial_HTML11, 
    Nothing, 
    PDFReportsConfig.BlackBrush, 
    y, x, 3, 2, tfo);
IMPORTANT: This is just some  text 
representing a paragraph.  This is 
just some  extra text  to make the 
paragraph                  longer.
ltrtxt += vbCrLf
ltrtxt += vbCr
ltrtxt += vbLf
也就是说:我分别尝试了这三个元素。

如果在文本末尾添加

html元素,最后一行将不再对齐

IMPORTANT: This is just some  text 
representing a paragraph.  This is 
just some  extra text  to make the 
paragraph longer.
请注意,较旧版本的PDF4NET可能需要

,而不是