PDFsharp换行符 [英] PDFsharp Line Break

查看:215
本文介绍了PDFsharp换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试换行,但是如果我使用\n则行不通.

I am trying to get new line but if I use \n it does not work.

通过向\r\n之类的字符串中添加一些东西来换行的任何方法(同样不起作用)

Any way to have new line by adding something to string like \r\n (which also does not work)

gfx.DrawString("Project No \n" + textBoxProjNumber.Text, fontUnder, XBrushes.Black, 230, 95);

(示例代码片段显示了我尝试过的方法,但是没有用).

(the example snippet shows what I've tried but does not work).

推荐答案

您是否尝试过XTextFormatter类?

Have you tried the XTextFormatter class?

请参阅此处: http://www.pdfsharp.net/wiki/TextLayout-sample.ashx

代码段:

PdfDocument document = new PdfDocument();

PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Times New Roman", 10, XFontStyle.Bold);
XTextFormatter tf = new XTextFormatter(gfx);

XRect rect = new XRect(40, 100, 250, 220);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

这篇关于PDFsharp换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆