On 06/02/17 13:10, Jano Crema wrote:
> void imprimir()
> {
> Fl_Printer printer;
> printer.start_job(1);
> printer.start_page();
> printer.margins(0,0,0,0);
> fl_draw("BOI DA CARA PRETA", 0, 0);
> printer.end_page();
> printer.end_job();
> }
I've never used Fl_Printer myself, but I tried your program
(on linux) and found I needed to add above fl_draw() settings
for fl_font() and fl_color().
Your margins() call does nothing because all four values are NULL;
those are supposed to be pointers to integers that receive the current
margin offsets, if I read the docs correctly. It does not /set/ the margins.
So what you probably want is:
#include <FL/Fl_Printer.H>
#include <FL/fl_draw.H>
void imprimir()
{
Fl_Printer printer;
printer.start_job(1);
printer.start_page();
int L,T,R,B; // ADDED
printer.margins(&L,&T,&R,&B); // CHANGED
printf("%d %d %d %d\n", L,T,R,B); // ADDED (prints what the margins are)
fl_color(FL_BLACK); // ADDED
fl_font(FL_HELVETICA, 20); // ADDED
fl_draw("TEST ABCDEF", -L, 0); // CHANGED: 0,0 -> -L,0
printer.end_page();
printer.end_job();
}
int main() {
imprimir();
}
The important changes are (a) getting the margins into L/T/R/B,
and then using the value for the left margin (L) as a negative offset
in fl_draw() to compensate for the margin offset (see -L in fl_draw())
That worked for me; it put the text as close to the left physical
printing area as possible.
There may be a way to use the translate method to effectively
do the same thing to all calls, making 0,0 the actual top/left of
the physical printing area -- I didn't try it.