Link to home
Start Free TrialLog in
Avatar of Chris McClenny
Chris McClennyFlag for United States of America

asked on

How do I print in Delphi7 without Form Feed after Printer.EndDoc command

How can I prevent Printer.EndDoc from sending a FormFeed at the end of the print job?  I am getting a blank page on the tail end of my print Job.  
If it is not possible, is there a better way to print?  Here is a general reconstruction of the code snippet in question...
 
  ILDocumentImage1.P_Begin_End_Doc:=FALSE;
  Printer.Begindoc;
 
  for i:=0 to ILDocumentImage1.TiffPageCount-1 do
      Begin
          PrintThisPage:=PDocData(CurrentNode.Data)^.ddPageList[i].dpSelectedForPrint;
          if PrintThisPage then
             Begin
   
                //Send print job to printer
                ILDocumentImage1.PrintDOC(0,0, Printer.PageWidth,Printer.PageHeight);

                if i < (ILDocumentImage1.TiffPageCount-1) then   Printer.NewPage;
             end;
          ILDocumentImage1.Next;
        end;

  Printer.EndDoc;
Avatar of vb_jonas
vb_jonas
Flag of Sweden image

Change the Printer.NewPage, because in your code - if your last page wont print (You have to have the same condition), the last printed page will add a blank page.

You could do like this (add a TheFirstPage boolean)

  ILDocumentImage1.P_Begin_End_Doc:=FALSE;
  Printer.Begindoc;
 
  TheFirstPage := True;
  for i:=0 to ILDocumentImage1.TiffPageCount-1 do
      Begin
          PrintThisPage:=PDocData(CurrentNode.Data)^.ddPageList[i].dpSelectedForPrint;
          if PrintThisPage then
             Begin
   
                //Send print job to printer, a new page before every page but the first
                if Not TheFirstPage Then Printer.NewPage;
                TheFirstPage := False;
                ILDocumentImage1.PrintDOC(0,0, Printer.PageWidth,Printer.PageHeight);

             end;
          ILDocumentImage1.Next;
        end;

  Printer.EndDoc;

Avatar of Chris McClenny

ASKER

vb_jonas...

I tried that and now only page 2, 3, and 2 blank pages print out.  
Before, it would print out page 1, 2, and 3 plus 1 blank page.

It's as if no matter what I try, Printer.EndDoc sends an extra Form Feed.
ASKER CERTIFIED SOLUTION
Avatar of vb_jonas
vb_jonas
Flag of Sweden 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