使用C ++ / CLI打印文本文件 [英] Printing a text file with C++/CLI

查看:128
本文介绍了使用C ++ / CLI打印文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们!很抱歉打扰你,但我需要一些帮助。



Mi应用程序创建一个用于打印的文本文件,但它在纸面上看起来不一样,当它来自带字符串的字符的水平间距。



我希望文本显示为列格式,所以我尝试使用水平制表符,向右填充字符串有空格,两者兼而有之。当我用记事本查看文件时,该文件看起来很完美;但是,当从应用程序中打印时,它似乎忽略了HT,并且单词之间的空格似乎没有相同的长度。)



我用这个格式化字体的声明:

Hi, Guys!. Sorry to bother you, but I need a little help.

Mi application creates a text file for printing, but it doesn't look the same on paper, when it comes to horizontal spacing of the characters withing strings.

I want the text to appear formatted as columns, so I've tried using horizontal tabs, padding strings to the right with spaces, and a combination of both. The file looks perfect when I view it with Notepad; but, when printed from within the application, it seems to ignore the HT's and the spaces between words don't seem to have the same length).

I use this statement to format the font:

printFont = gcnew System::Drawing::Font( "Lucinda Console",10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point); 





你可以给我一只手,请?感谢提前!



CAN YOU GIVE ME A HAND,PLEASE? THANKS IN ADVANCE!

推荐答案

使用固定宽度的字体,您的打印输出应该没问题(应该看起来像在记事本上)。

With a fixed-width font your printout should be fine (should look like it does on the notepad).
Quote:

printFont = gcnew System :: Drawing :: Font(Lucinda Console,10,System :: Drawing :: FontStyle :: Regular,System :: Drawing :: GraphicsUnit :: Point);

printFont = gcnew System::Drawing::Font( "Lucinda Console",10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point);

请注意字体的名称是Lucida Console,而不是Luci n da Console。

Please note the name of the font is "Lucida Console", not "Lucinda Console".


大家好!感谢您的回复,并抱歉 Lucinda



这就是我解决它的方式。我累了,看不出它有多容易:



1)我将要打印的行拆分为所需的列数(使用HT作为分隔符并忘记填充)。



2)我还使用了函数的不同实例

Hi, guys! THANKS FOR YOUR REPLIES, and sorry about "Lucinda".

This is how I solved it. I was tired and couldn't see how easy it was going to be:

1) I split up the line to be printed in as many parts as columns needed (using HT's as separators and forgetting about padding).

2) I also used different instances of the function
ev->Graphics->DrawString(column1, printFont, Brushes::Black, leftMargin, yPos, gcnew StringFormat);




每个要打印的零件的b $ b,保持相同的yPos,但是将左边距增加适当的数量,以使项目打印在同一条线上,但位于不同的固定位置。

现在我有我想要的东西。



再次感谢!!!


这篇关于使用C ++ / CLI打印文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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