2014-03-28 42 views
5

我似乎无法理解如何在我使用PDFsharp创建的矩形内包装文本。我已经看过文章解释如何,但是当我尝试它时,我的文本仍然延伸到PDF页面。任何帮助都会很棒(这是我第一次使用PDFsharp)。PDFsharp文字包装

rect = new XRect(20, 300, 400, 100); 
tf.Alignment = XParagraphAlignment.Left; 
gfx.DrawString("\t • Please call the borrower prior to closing and confirm your arrival time and the closing location. \n", font, XBrushes.Black, rect, XStringFormats.TopLeft); 
rect = new XRect(20, 320, 100, 100); 
gfx.DrawString("\t • If the borrower needs to change the closing appointment time or date for any reason please have them call McDonnell Law Firm at 866-931-8793 \n", font, XBrushes.Black, rect, XStringFormats.TopLeft); 
rect = new XRect(20, 340, 100, 100); 
gfx.DrawString("\t • Completed documents must be received same day. Fax back to 888-612-4912 or email [email protected] \n", font, XBrushes.Black, rect, XStringFormats.TopLeft); 
rect = new XRect(20, 360, 100, 100); 
gfx.DrawString("\t • Documents are to be returned via Fedex or UPS with shipping label provided. Documents must be dropped same day. \n", font, XBrushes.Black, rect, XStringFormats.TopLeft); 

这是它在做什么>enter image description here

+1

什么是*问题*?请更具体一些。 – Dmitry

+0

我添加了一张照片。文本正在离开页面。我已经改变了矩形的宽度,但没有区别。 – MaylorTaylor

+2

我相信他的意思是“似乎无法理解......” – jmstoker

回答

9

从您的代码段我认为tf是XTextFormatter类的对象,而gfx是XGraphics对象。

XGraphics.DrawString不支持换行符。

XTextFormatter.DrawString支持换行符。

代码中的错误:您打电话给gfx.DrawString,您打算拨打电话tf.DrawString