Click here to Skip to main content
15,883,535 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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:
C++
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!
Posted
Comments
Nelek 28-Jun-13 13:11pm    
I don't think it is related with the font.

Maybe if you use the "improve question" and you add a snippet of your print function, someone here can give you more information or even a solution.

I am not sure about CLI, but I did (long ago) my printing using the pDC (VC++ 6.0 with MFC) and you have to give everything you want to be printed and is not the "standard way", and even when you do, if you don't do it correctly relating the pDC to the Device-Settings it can be the hell when changing to another printer.

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);
Please note the name of the font is "Lucida Console", not "Lucinda Console".
 
Share this answer
 
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
C++
ev->Graphics->DrawString(column1, printFont, Brushes::Black, leftMargin, yPos, gcnew StringFormat);


for each part to be printed, keeping the same yPos but incrementing the left margin by the appropriate amount to have items printed on the same line but at different, fixed positions.
Now I have what I wanted.

THANKS AGAIN!!!
 
Share this answer
 
Comments
hyderali_s 2-Aug-13 2:11am    
Hi
Mateo Hernández330
,
Will your code work for all paper sizes and font? Could you please share your code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900