Formatting text using PDFsharp

≡放荡痞女 提交于 2019-12-25 11:35:56

问题


I want to apply style to

string "Helloword"

and have style properties

like fontFamily='Verdana', fontStyle='bold', FontSize='12', textDecoration='underline', textAlign='center', fontColor='#FF0000', x=100 and y=100.

I want to display this string in PDF using PDFsharp. can anyone suggest me how to do that?

I'm using XFont and XGraphics.DrawString method but I'm not able to apply all above styles.


回答1:


The string is slightly incorrect, but I hope all other requirements are met:

// Create a font
XFont font = new XFont("Verdana", 12, XFontStyle.Bold | XFontStyle.Underline);

// Draw the text
gfx.DrawString("Hello, World!", font, new XSolidBrush(XColor.FromArgb(255, 0, 0)),
  100, 100,
  XStringFormats.Center);


来源:https://stackoverflow.com/questions/17759711/formatting-text-using-pdfsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!