将对齐的段落转换为图像
我需要将一段文本转换为图像。将文本转换为图像是没有问题的。我有代码可以做到这一点。但文本必须显示为每行居中的段落。那是个问题!
目前,我可以将文本转换为左对齐段落,因为文本字符串中有回车符。我想它可以用字符串中的空格居中对齐,但很难计算所需的空格。一定有更简单的方法。
我需要的是某种方法将文本格式化为段落,然后将其转换回字符串,并保留空格。对于 ASP.NET Web 应用程序,这需要在 VB.NET 中完成。
有什么想法吗?我可以使该段落以富文本格式对齐,但我不知道是否可以将其转换回字符串,并保留空格。创建 PDF 是另一种可能性。
从文本创建的图像需要为 300 DPI,且背景透明。我使用 Graphics 对象的 DrawString 方法来创建图像。
I need to convert a paragraph of text into an image. Converting the text into an image is no problem. I have the code to do that. But the text must be shown as a paragraph with each line centered. That is a problem!
Currently I can convert the text into a left justified paragraph because there are carriage returns in the text string. I suppose it could be center justified with spaces in the string but it would be hard to calculate the required spaces. There must be an easier way.
What I need is some way to format the text into a paragraph and then convert it back into a string, preserving spaces. This needs to be done in VB.NET for an ASP.NET web application.
Any ideas? I could get the paragraph justified in Rich Text Format but I don't know if it can be converted back into a string, preserving spaces. Creating a PDF is another possibility.
The image created from the text needs to be 300 DPI with a transparent background. I'm using the DrawString method of a Graphics object to create the image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我试图解决同样的问题,我会利用以下资源:
查看以下 imagemagick 页面的带有段落的标题部分:http://www.imagemagick.org/Usage/text/
页面下方是有关居中文本的信息。
If I were trying to solve the same problem, I would utilize the following resource:
View the Captions with Paragraphs section of the following imagemagick page: http://www.imagemagick.org/Usage/text/
Below that on the page is information on centering text.