[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: kdeprint problem
From: Tomasz Grobelny <grotk () poczta ! onet ! pl>
Date: 2001-06-14 21:05:31
[Download RAW message or body]
On Thursday 14 June 2001 10:33, Michael Goffioul wrote:
> Tomasz Grobelny wrote:
> > I wrote such a function:
> >
> > void DocumentPrinter::OnPrint(){
> > printer=new KPrinter;
> > printer->setup(this);
> > QPainter p;
> > if(!p.begin(printer))
> > return;
> > p.setFont(QFont("times",10));
> > QFontMetrics fm = p.fontMetrics();
> > QPaintDeviceMetrics metrics( printer );
> > double aspectX=(double)metrics.width()/(double)metrics.widthMM();
> > double
> > aspectY=(double)metrics.height()/(double)metrics.heightMM(); int sx=35,
> > ex=175, sy=87;
> > sx*=aspectX;
> > sx-=printer->margins().width();
> > ex*=aspectX;
> > ex-=printer->margins().width();
> > sy*=aspectY;
> > sy-=printer->margins().height();
> > QRect qaz(sx, sy-fm.lineSpacing(), ex-sx, fm.lineSpacing());
> > p.drawText(qaz, AlignBottom|AlignHCenter,"Test Text");
> > p.drawRect(qaz);
> > p.end();
> > }
>
> 2 things:
> - you should _test_ the printer setup
Test page prints OK (From KUPS/Mandrake).
> - in this case you'd better use fullPage printing (without any margin)
Can't use full page because ps files are not correct. I tried to see them
using gv and I received the following error-report:
Error: /syntaxerror in -file-
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval--
--nostringval-- 2 %stopped_push --nostringval-- 2 3 %oparray_pop
--nostringval-- --nostringval-- false 1 %stopped_push 1 3
%oparray_pop 1 3 %oparray_pop .runexec2 --nostringval--
--nostringval-- --nostringval-- 2 %stopped_push --nostringval--
--nostringval--
Dictionary stack:
--dict:906/941(G)-- --dict:0/20(G)-- --dict:109/200(L)--
Current allocation mode is local
Current file position is 2898
>
> This gives you (works for me):
>
> void DocumentPrinter::OnPrint(){
> printer=new KPrinter;
> printer->setFullPage(true);
> if (printer->setup(this)){
> QPainter p;
> if(!p.begin(printer))
> return;
> p.setFont(QFont("times",10));
> QFontMetrics fm = p.fontMetrics();
> QPaintDeviceMetrics metrics( printer );
> double aspectX=(double)metrics.width()/(double)metrics.widthMM();
> double
> aspectY=(double)metrics.height()/(double)metrics.heightMM(); int sx=35,
> ex=175, sy=87;
> sx*=aspectX;
> ex*=aspectX;
> sy*=aspectY;
> QRect qaz(sx, sy-fm.lineSpacing(), ex-sx, fm.lineSpacing());
> p.drawText(qaz, AlignBottom|AlignHCenter,"Test Text");
> p.drawRect(qaz);
> p.end();
> }
> }
Does not work at all. See above.
Tomasz Grobelny
--
Ile zarabiasz? Wypelnij ankiete,
dowiesz sie jak zarabiac wiecej [ http://listaplac.onet.pl ]
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic