2014-03-28 127 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