Page 1 of 1

problem with images printed like filled black square

Posted: Thu Sep 22, 2005 9:45 am
by vanio
We have a very strange problem: sometimes images included in richview are printed as black square! :cry:
This may happend with casuality and with many different priters and OS's. For example, if i print a mail-merge document of 20 records, may be that 2 or 3 pages have a black square instead of the real image! Does someone have any ideas? :idea:

Posted: Thu Sep 22, 2005 10:03 am
by Sergey Tkachenko
If you use older version of TRichView, update to newer version.

Play with the printer driver's options (button Properties near the list of printers in the Print dialog). Try to turn off "optimization of pictures" or things like this.

Posted: Thu Sep 22, 2005 10:22 am
by Stef
I've tried all those tricks and they didn't help.
Most annoying is that the results are not reproducable.
Most problems we've found were with HP printers,
tried both latest MS and latest HP drivers,
but problem randomly occures.

HP drivers?

Posted: Thu Sep 22, 2005 4:10 pm
by vanio
I confirm that many problems happend with HP printers.

seems to be a tipical delphi problem with hp printers

Posted: Thu Sep 22, 2005 4:45 pm
by vanio
I've found this interesting discussion....
http://groups.google.com/group/borland. ... 8ec5fc63ee

Posted: Thu Sep 22, 2005 5:42 pm
by Sergey Tkachenko
From the related thread I found intersting info that GetDiBits fails if the memory is allocated using GetMem. Not too useful, because TRichView printing code uses GlobalAlloc there. But for any case, I'll replace all calls of GetMem in the picture printing procedure.

Posted: Sat Sep 24, 2005 1:44 pm
by Stef
I just discovered that the black images sometimes also appeared in pdf creation. Unfortunatly I cann't reproduce the problem anymore, because I don't have the exact sources. I do have a pdf document, printed from RVE, with black rectangles in it, but I doubt if that is of any use.

My suggestion is that if anyone gets a black rectangle printed instead of the picture, to print the same document to pdf, in the hope that it will also show the black rectangle. In that way we can provide Sergey with a reproducable example. (I use the freeware PDFCreator)

thanks,

Posted: Sun Sep 25, 2005 8:52 am
by Sergey Tkachenko
I belive that black rectanges on paper and in PDF (never seen them, probably they depend on PDF generation tool) have different nature

Posted: Sun Sep 25, 2005 9:06 am
by Stef
You could be right,
but why not try it,
because if it shows up in both printer and pdf,
it's likely that there is a common cause.

To indicate how rare it is,
the pdf docuement I'm talking about has about 300 .. 400 pictures,
and only 2 of them (sometimes) comes up as black squares.

cheers,

Posted: Sun Sep 25, 2005 10:04 am
by Stef
I forgot to mention,
pdfCreator is an pdf-printer,
so RVE just sees it as a normal printer,
and thus there could be a cause of the same nature.

cheers,

Posted: Sun Oct 02, 2005 10:46 pm
by Stef
I'm not sure, but I just discovered an error (which I never realized and thus is in all my programs, I think it's also not correct in the RV examples), which might be the causeof this problem.

I do printing always through a printersetup dialog,
and I forget to reformat after the user selects a different printer.

here is the correct code

Code: Select all

  RVPrint1.AssignSource(RVE_mother);
  RVPrint1.FormatPages(rvdoALL);

  if rvpp.RVPrint.PagesCount=0 then exit;

  with printdialog1 do
  begin
    minpage:=1;
    maxpage:=rvpp.RVPrint.PagesCount;
    frompage:=minpage;
    topage:=maxpage;
    old_printer:=printer.printerindex;
    if execute then
    begin
      if old_printer<>printer.PrinterIndex then             // <== these lines are essential
        RVPrint1.FormatPages(rvdoALL);                    // <== these lines are essential
      if printrange=prAllPages then
        tRVPrint(rvpp.RVPrint).Print('PuntHoofd',1,False)
      else
        RVPrint1.Printpages(frompage,topage,'PuntHoofd',1,false);
    end;
  end;

Posted: Mon Oct 03, 2005 4:17 pm
by Sergey Tkachenko
Moreover, I recommend to call FormatPages after displaying the print dialog even if the current printer was not changed, becase the user may change some properties affecting printing.