如何在PrintDocument中制作文本下标? [英] how to make a text Subscript in PrintDocument?

查看:72
本文介绍了如何在PrintDocument中制作文本下标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想在PrintDocument打印页面打印下标文本(如HBA IC )。

我搜索过在谷歌但我找不到任何解决方案..

所以,我写这段代码:

字体ftNormal =  new  System.Drawing.Font(  Arial,< span class =code-digit> 12 ); 
e.Graphics.DrawString( HBA IC,ftNormal,Brushes.Black,< span class =code-digit> 20 , 50 );



我没有关于这一点的想法,是否需要计算文本大小或其他内容以打印该文本为下标?



先谢谢。



问候

Jayanta。

解决方案

我用@BillWoodruff建议的Unicode解决了我的问题。 。



我从这个网站找到了Unicode字符: Unicode字符列表 [ ^ ],然后复制unicode并将其粘贴到代码。



我的代码变为:

 e.Graphics.DrawString(  HBAɪς,ftNormal,Br ushes.Black, 20  50 ); 





感谢Sir,

Quote:

@BillWoodruff


这篇(C ++)文章可能会帮助您:在设备上下文中显示文本时使用下标和上标:[ ^ ]。



您是否考虑过使用Unicode Escape格式化以生成下标...我不确定它是否适用于PrintDocument。



如果您最终使用的是RichTextBox,请参阅此MSDN中的文章除了链接谢尔盖引用:[ ^ ]。



如果你找到一个好的解决方案,我建议你把它作为'提示/技巧'发布在这里。

我建​​议使用RTF来实现具有这种格式(以及更多)的内容。这篇旧的MSDN文章解释了如何执行此操作: https://support.microsoft.com/en-us/kb/ 812425 [ ^ ]。



此外,有一种很好的方法可以将 RichTextBox 内容呈现为此CodeProject文章中提供的HTML:您将使用的专业HTML渲染器 [ ^ ]。



确实,使用 RichTextBox 进行格式化控制非常尴尬。 HTML更容易。所有RTF格式化工作已经完成。



-SA


Hi All,
I want to print a subscript text(like "HBA IC") in PrintDocument print page.
I searched on Google but I couldn't find any solution..
So, I write this code:

Font ftNormal = new System.Drawing.Font("Arial", 12);
 e.Graphics.DrawString("HBA IC",ftNormal,Brushes.Black,20,50);


I have no idea about this, is there need to calculate the text size or somthing else to print that text as a subscript?

Thanks in advanced.

Regards
Jayanta.

解决方案

I solve my problem with the Unicode which suggested by @BillWoodruff..

I found the Unicode Characters from this site: Unicode Characters List[^], then copy the unicode and paste it to in the code.

My code become:

e.Graphics.DrawString("HBA ɪϲ ", ftNormal, Brushes.Black, 20, 50);



thanks to Sir,

Quote:

@BillWoodruff


This (C++) article might assist you: "Using Subscripts and Superscripts When Showing Text in the Device Context:" [^].

Have you looked into using Unicode Escape formatting to produce subscript ... I'm not sure if that works with PrintDocument.

If you do end up using a RichTextBox, see this MSDN article in addition to the link Sergey cites: [^].

If you find a good solution, I'd like to suggest you post it here as a 'Tip/Trick.'


I suggest to implement the content with such kind of formatting (and a lot more) using RTF. This old MSDN article explains how to do that: https://support.microsoft.com/en-us/kb/812425[^].

Moreover, there is a good way to render RichTextBox content as HTML provided in this CodeProject article: A Professional HTML Renderer You Will Use[^].

Indeed, formatting control with RichTextBox quite awkward. HTML is much easier. All the RTF formatting work is already done for you.

—SA


这篇关于如何在PrintDocument中制作文本下标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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