如何如实地将RTF写入打印机 [英] How to write faithfully a RTF to a printer

查看:68
本文介绍了如何如实地将RTF写入打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要了解将RTF文档(来自RTF文本框)写入打印机的规则.为了实现这一点,我一点一点地考虑了字符并确定了宽度(和Heigth).宽度乘以一个比例常数,如果超过 在边框上创建新行.

绘图代码如下所示

    e.Graphics.DrawString(dis,FontAttuale,spazzo,X-e.Graphics.MeasureString(dis,FontAttuale).Width * .17f,
                                    Y + kapk);
                               如果(dis!="")
                                    X-= e.Graphics.MeasureString(dis,FontAttuale).Width * .17f * omotetX;
                                X + = e.Graphics.MeasureString(dis,FontAttuale).Width * omotetX;

但是有时候行太长而另一些行太短:为什么?

请注意,已考虑缩进:请参见代码(X-= ...)

我感谢eveyone答复

解决方案

您好molokko,

谢谢您在这里发布.

对于您的问题,您的项目是什么? Windows窗体还是WPF?更多细节会有所帮助.

根据我的搜索,这是有关"如何:保存,加载和打印RichTextBox内容".

我希望这会对您有所帮助.

最好的问候,

温迪


I need to know the rules to write a RTF document (from a richtextbox) to the printer. to achieve this I take the characters bit by bit and obteining the width (and the Heigth). The widths are multiplaied by a constant of proportionality and if they exceed the border a new line is created. 

the code for drawing is showed below

   e.Graphics.DrawString(dis, FontAttuale, spazzo, X - e.Graphics.MeasureString(dis, FontAttuale).Width * .17f,
                                    Y + kapk);
                                if (dis != " ")
                                    X -= e.Graphics.MeasureString(dis, FontAttuale).Width * .17f * omotetX;
                                X += e.Graphics.MeasureString(dis, FontAttuale).Width * omotetX;

Howhever some times the line is too long and others is too short:why? 

Note thath the indent is considered:see the code (X-=...)

I thank eveyone who reply

解决方案

Hi molokko,

Thank you for posting here.

For your question, what is your project? A Windows Form or WPF? More details would be helpful.

Based on my search, here is an tutorial about "How to: Save, Load, and Print RichTextBox Content". 

I hope this would be helpful to you.

Best Regards,

Wendy


这篇关于如何如实地将RTF写入打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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