Link to home
Start Free TrialLog in
Avatar of Treppenmeister
Treppenmeister

asked on

Delphi problems to abort a printjob

With several printers I have problems to abort a print job and start another one.
(my main problem printer is a Konica Minolta Bizhub C364e, driver version 5.1.3)

The job will be aborted but the next one won't  be printed.

printer.title := 'job 1';
printer.begindoc;
printer.abort;

printer.title := 'job 2';
printer.begindoc;
printer.abort;

printer.title := 'job 3';
printer.begindoc;
... print some data ...
printer.enddoc

Open in new window


The first job will be aborted (with abort). But the remaining jobs not - they also won't be printed. They appear in the list of printing jobs but seem to have all a size of 0.
How can I avoid something like that?
I am afraid that this is a driver problem - but there are no newer printer drivers available.

It is a network printer. If I print into a file then job1 and job2 are 0 byte and job 3 1.6 MB. So printing into a file seems to work (same printer)


WIndows 7, 64 bit


Edit:
This seems to be only a problem when I use the printer spooler (which is default setting in windows). If I print directly to the printer all works fine.
Is there a way to find out that something isn't working well (within of the application which is printing)?
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Why !! do you call begindoc and after that abort?

Regular way is to do begindoc + enddoc.
printer.begindoc;
try
... print some data ...
  printer.enddoc;
except
  printer.abort;
end;

Open in new window

you call abort only on error. if you don't want to print - do not send to print ....
Avatar of Treppenmeister
Treppenmeister

ASKER

I need the handle of the printer to calculate the output. I have a mix of text and technical drawings. The text is reducing the available rect for the drawing and I have to know at which scale I can print on a given paper size.
DrawText wants the handle. And I can access printer.handle only after I start begindoc, After calculating I abort.  I don't print anything at that time.

Or do you have a better idea how to use DrawText?


In the meanwhile I found out that I have only problems with the Konica Minolta PCL6 driver. The postscript driver behaves well.
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, I will try to use the tMetaFile for calculation.  
I always thought that the canvas was limited. Similar to the size of the paper of the printer which I cannot set to values above 2^15 (1/10 mm). So a print job larger than 3.27 m I cannot generate (set).
So I never tried it since the outputs can be larger that 3.27 m

So for calculation I have to set only width, height and the dpi for width and height. Or do I miss something?
It seems to work. But I have to set the dpi before assigning the font. Otherwise font size does not fit.
So dpi is important

MyMetaFilecanvas.Font.PixelsPerInch := GetDeviceCaps( Printer.Handle , LogPixelsX );
MyMetaFilecanvas.Font.Assign( MyFont );

Open in new window


Are there any windows printer with different dpi in x and y?
I know that there can be differences  when I have to print directly on old dot matrix printer (via Esc sequences). But doing so I ignore windows printer driver.
Using the tMetaFile solved my original problem.
I think that dpi for x and y is a same ...
Implementing everything in my code worked well.  By doing so I realised that I used tMetafile already for my preview window. But not for the pre-calculation of the scale. So everything is fine now.
And thanks again!