|
|
Home » U++ Library support » LineEdit, EditFields, DocEdit » How to Print a file inside LineEdit
|
Re: How to Print a file inside LineEdit [message #3230 is a reply to message #3227] |
Sun, 14 May 2006 21:44   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
forlano wrote on Sun, 14 May 2006 13:34 | Hello,
I've a file in a LineEdit widget and I desire to send it to the Printer. I've found with Assist the Print() function but it seems to work with RichText while I've a simple text file. So I wonder if it works or there is a U++ Print method that can do the job. (At the moment I've not a printer so I cannot test if the Print() method RichTest based works in my case).
BTW, this question is more general because in principle I could want to print a text file bypassing any widget and sending it directly to the printer.
Thank you,
Luigi
PS: The class RichEdit has the Print() method, why LineEdit has not the same?
|
There is no direct support for printing of LineEdit.
The simplest way to print is to use Report. Simply, instead to sending your stuff to "Draw", you use Report (which implements Draw interface), just add some calls to perform pagination. Alternatively, use Qtf, which you can send to Report as well.
Mirek
|
|
|
Re: How to Print a file inside LineEdit [message #3240 is a reply to message #3230] |
Mon, 15 May 2006 21:09   |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
luzr wrote on Sun, 14 May 2006 21:44 | The simplest way to print is to use Report. Simply, instead to sending your stuff to "Draw", you use Report (which implements Draw interface), just add some calls to perform pagination. Alternatively, use Qtf, which you can send to Report as well.
Mirek
|
I tried Report. Perhaps I do some mistake but doesn't seems so immediate. Let's neglect for the moment the pagination and let assume I've only one page to print. I tried the following code:
void VegaTab4::PrintCB()
{ Report r;
// r.Header("[A2> Page $$P");
r << "Round 1";
r << "===================================================================";
r << " 1 = 4 Karpov, Igor - 2 Karpov, Vadim = 1 - 0";
r << "-------------------------------------------------------------------";
Print( r, 1, "Preview");
// Perform(r); //same format error
}
When I run it appear the print panel. Then I click print and I observe the result attached below (I've printed with a pdf driver and then get a screenshot).
So it seems Report try to interpret the strings in qtf terms. This means that my text file is processed as a qtf file while it has no format command and I want to send to the printer each character the file contains.
Before to obtain this error I believed I could get the entire text file and pass via << to r and then print it. But now seems I cannot avoid to save the file in qtf format. Am I right?
Anyway I think could be very useful to have a very direct way to communicate with a printer without any inteference and control about font etc. With linux I could use a calling to system and print via 'lp', but with windows I would like to have the possibility to choose at least the printer.
Luigi
-
Attachment: swiss5.jpg
(Size: 8.68KB, Downloaded 2102 times)
|
|
|
Re: How to Print a file inside LineEdit [message #3242 is a reply to message #3240] |
Mon, 15 May 2006 22:00   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
forlano wrote on Mon, 15 May 2006 15:09 |
luzr wrote on Sun, 14 May 2006 21:44 | The simplest way to print is to use Report. Simply, instead to sending your stuff to "Draw", you use Report (which implements Draw interface), just add some calls to perform pagination. Alternatively, use Qtf, which you can send to Report as well.
Mirek
|
I tried Report. Perhaps I do some mistake but doesn't seems so immediate. Let's neglect for the moment the pagination and let assume I've only one page to print. I tried the following code:
void VegaTab4::PrintCB()
{ Report r;
// r.Header("[A2> Page $$P");
r << "Round 1";
r << "===================================================================";
r << " 1 = 4 Karpov, Igor - 2 Karpov, Vadim = 1 - 0";
r << "-------------------------------------------------------------------";
Print( r, 1, "Preview");
// Perform(r); //same format error
}
When I run it appear the print panel. Then I click print and I observe the result attached below (I've printed with a pdf driver and then get a screenshot).
So it seems Report try to interpret the strings in qtf terms. This means that my text file is processed as a qtf file while it has no format command and I want to send to the printer each character the file contains.
Before to obtain this error I believed I could get the entire text file and pass via << to r and then print it. But now seems I cannot avoid to save the file in qtf format. Am I right?
Anyway I think could be very useful to have a very direct way to communicate with a printer without any inteference and control about font etc. With linux I could use a calling to system and print via 'lp', but with windows I would like to have the possibility to choose at least the printer.
Luigi
|
You can "avoid" qtf by calling DeQtf for texts you pass... That will add escape characters that will "quote" original text in Qtf.
void VegaTab4::PrintCB()
{ Report r;
// r.Header("[A2> Page $$P");
r << "Round 1";
r << DeQtf("===================================================================");
r << DeQtf(" 1 = 4 Karpov, Igor - 2 Karpov, Vadim = 1 - 0");
r << DeQtf("-------------------------------------------------------------------");
Print( r, 1, "Preview");
// Perform(r); //same format error
}
Mirek
[Updated on: Mon, 15 May 2006 22:01] Report message to a moderator
|
|
|
Re: How to Print a file inside LineEdit [message #3244 is a reply to message #3242] |
Mon, 15 May 2006 23:13   |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
luzr wrote on Mon, 15 May 2006 22:00 |
You can "avoid" qtf by calling DeQtf for texts you pass... That will add escape characters that will "quote" original text in Qtf.
void VegaTab4::PrintCB()
{ Report r;
// r.Header("[A2> Page $$P");
r << "Round 1";
r << DeQtf("===================================================================");
r << DeQtf(" 1 = 4 Karpov, Igor - 2 Karpov, Vadim = 1 - 0");
r << DeQtf("-------------------------------------------------------------------");
Print( r, 1, "Preview");
// Perform(r); //same format error
}
Mirek
|
I tried and it works. Unfortunatly there is again one more problem : by default it is set the proportional font. Instead i would like to print with courier font to preserve the vertical alignment present in the file. Using UWord I got the format command to print with courier, say 11. So I've tried to embed one text line in a formatted command line with courier font like this:
void VegaTab4::PrintCB()
{ Report r;
r << "[ $$0,0#00000000000000000000000000000000:Default]"
"[{_}%EN-US"
"[s0;C+92 Round 1 ]"; //it's OK
r << "[s0;C+92 " << DeQtf("Round 1") << " ]"; // doesn't work
r << "[s0;C+92 " << DeQtf("=====================================================") <<" ]" ;
Print( r, 1, "Preview");
}
This produce problem (see attached picture) because do not recognise the final " ]" and this seems strange to me.
I've even tried
with no success. So, is there a way to set by default the Courier font?
Luigi
-
Attachment: swiss6.jpg
(Size: 8.58KB, Downloaded 3105 times)
|
|
|
Re: How to Print a file inside LineEdit [message #3245 is a reply to message #3244] |
Tue, 16 May 2006 01:35   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
forlano wrote on Mon, 15 May 2006 17:13 |
luzr wrote on Mon, 15 May 2006 22:00 |
You can "avoid" qtf by calling DeQtf for texts you pass... That will add escape characters that will "quote" original text in Qtf.
void VegaTab4::PrintCB()
{ Report r;
// r.Header("[A2> Page $$P");
r << "Round 1";
r << DeQtf("===================================================================");
r << DeQtf(" 1 = 4 Karpov, Igor - 2 Karpov, Vadim = 1 - 0");
r << DeQtf("-------------------------------------------------------------------");
Print( r, 1, "Preview");
// Perform(r); //same format error
}
Mirek
|
I tried and it works. Unfortunatly there is again one more problem : by default it is set the proportional font. Instead i would like to print with courier font to preserve the vertical alignment present in the file. Using UWord I got the format command to print with courier, say 11. So I've tried to embed one
text line in a formatted command line with courier font like this:
void VegaTab4::PrintCB()
{ Report r;
r << "[ $$0,0#00000000000000000000000000000000:Default]"
"[{_}%EN-US"
"[s0;C+92 Round 1 ]"; //it's OK
r << "[s0;C+92 " << DeQtf("Round 1") << " ]"; // doesn't work
r << "[s0;C+92 " << DeQtf("=====================================================") <<" ]" ;
Print( r, 1, "Preview");
}
This produce problem (see attached picture) because do not recognise the final " ]" and this seems strange to me.
I've even tried
with no success. So, is there a way to set by default the Courier font?
Luigi

|
There is one tricky thing about Report::operator<< - it takes each call as separate qtf text. So
r << "[s0;C+92 " << DeQtf("Round 1") << " ]";
makes for 3 separate texts.
To fix it, simply add texts together:
r << "[s0;C+92 " + DeQtf("Round 1") + " ]";
(Note that adding here is possible becase DeQtf returns String).
Mirek
|
|
|
|
Re: How to Print a file inside LineEdit [message #3260 is a reply to message #3250] |
Tue, 16 May 2006 22:11   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
Well, there is one important thing to know about U++ "distances".
Basically said, if the output goes to the screen, they are in pixels.
However, if there is "physical representation" (paper from the printer, or e.g. PDF which is in fact paper from the printer again), U++ uses "dots", where dot is defined as "pixel in 600dpi resolution".
And that is what GetSize returns. Actually, those numbers are choosen for A4 page and are indeed quite conservative (in fact, most printers are capable printing in much wider area, but it is different for each printer). When Report prints the page out, it takes "printer" page dimension and centres report size whithin it.
Mirek
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:32:38 CEST 2025
Total time taken to generate the page: 0.00992 seconds
|
|
|