PrintPreview and grayscale

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

PrintPreview and grayscale

Postby KnotATypo » January 5th, 2006, 10:43 pm

Just ran into a problem. Have a page set up that uses Times New Roman font, some of the text is colored clBlue, some clGray, also have a small graphic that uses clGray, other graphics (lines) are all clBlack.

Preview is fine, printing to a Xerox printer is fine (every thing gets grayscaled), but printing to a HP printer only the text and graphics that are clBlack get printed, any other color is not printed at all. This printer does print in grayscale.

Ideas, fixes?

TIA
KnotATypo
Member
Member
 
Posts: 3
Joined: January 5th, 2006, 10:33 pm

Postby Kambiz » January 6th, 2006, 1:55 pm

I guess you should update your HP printer's driver.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2405
Joined: March 7th, 2003, 7:10 pm

Postby KnotATypo » January 6th, 2006, 3:03 pm

That would have been my first guess, except that printing other graphics to this printer (with the same computer) does print the colors grayscaled correctly.

This is my code in a nutshell...
Code: Select all
//the main form
procedure TForm1.OnCreatePages(Sender: TPrintPreview);
begin
  Sender.GetPrinterOptions;
  Sender.BeginDoc;

  //...

  Sender.EndDoc;
end;

//the form that shows the preview
procedure TPrintPreviewDlg.PrintBtnClick(Sender: TObject);
var
  dlg : TSimplePrintDlg;
  mr : TModalResult;
begin
  //simple printing dialog
  dlg := TSimplePrintDlg.Create(Self);
  try
    dlg.Pages := PrintPreview1.TotalPages;
    dlg.PagesRBtn.Enabled := PrintPreview1.TotalPages > 1;

    mr := dlg.ShowModal;
    if mr = mrOk then begin
      Update;

      if dlg.AllRBtn.Checked then
        PrintPreview1.Print
      else
        PrintPreview1.PrintPages(dlg.PagesFromTo.X, dlg.PagesFromTo.Y);
    end else
      //if printer properties were changed (printer, orientation...)
      if mr = mrRetry then begin
        //main form OnCreatePages()
        if Assigned(FOnCreatePages) then
          FOnCreatePages(PrintPreview1);
      end;

  finally
    dlg.Free;
  end;
end;
KnotATypo
Member
Member
 
Posts: 3
Joined: January 5th, 2006, 10:33 pm

Postby Kambiz » January 30th, 2006, 6:52 pm

As you said, on some printers the colored text (except RTF) is not printed at all. But, there's no problem for images.

Fortunately I could find a workaround for this issue. The folowing lines of code should be called before drawing the text.

Code: Select all
SetBkColor(Canvas.Handle, RGB(255, 255, 255));
SetBkMode(Canvas.Handle, TRANSPARENT);

It's clear that the bug is inside the printer driver.

Cheers
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2405
Joined: March 7th, 2003, 7:10 pm

Postby KnotATypo » January 30th, 2006, 11:56 pm

Thanks,
Chris
KnotATypo
Member
Member
 
Posts: 3
Joined: January 5th, 2006, 10:33 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 2 guests

cron