problem with images printed like filled black square

General TRichView support forum. Please post your questions here
Post Reply
vanio

problem with images printed like filled black square

Post 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:
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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.
vanio

HP drivers?

Post by vanio »

I confirm that many problems happend with HP printers.
vanio

seems to be a tipical delphi problem with hp printers

Post by vanio »

I've found this interesting discussion....
http://groups.google.com/group/borland. ... 8ec5fc63ee
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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,
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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,
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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,
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Post Reply