#1 2013-09-17 10:00:40

Patacon
Member
Registered: 2013-09-17
Posts: 1

MormotReport is making black images in PDF

I'm having a weird problem with MormotReport.pas creating pdf files.  I use the unit to print to a pdf file (at most) 6 images using DrawBMP.  The first One is always fine, the rest of them, sometimes just print a black box the size of the image.  Usually 1 and 3 are fine, 2,4,5,6 are black.  I Verified the source of the graphics saving to disk the image after printing to pdf  and allways works fine.  I tried to use PDF.ForceNoBitmapReuse := True without any luck (bigger files but same black boxes).  I also tried using 6 different bmp vars, creating bmp before every image print and freeing the bmp var after printing with no luck.  Some little changes make results change.  Printing a lot of texts after o before every image, o printing a very small bmp before the normal ones tends to print more correct images but not all of them.   If I try a step by step run, the program works fine, so I can not see why is not working.  Thank you in advance for anything you can do to help me.... (ps. sorry for my bad English).

          ...   Basically I repeat this block six times with 6 different images...

           Bmp := TBitmap.Create;
           Form1.Image1.Picture.LoadFromFile('Fondo5.jpg');
           Bmp.Width := Form1.Image1.Picture.Width;
           Bmp.Height := Form1.Image1.Picture.Height;
           Bmp.Canvas.Draw(0, 0,Form1.Image1.Picture.Graphic);
           NewPage(True);
                TextAlign := taJustified;

               DrawText(s);
                NewLine;

           DrawTitle('Imagen #'+IntTostr(i),true);
           NewLine;
           DrawBMP(bmp,maxint,180,'Imagen #'+IntTostr(i));
          //bmp.savetofile('test6.bmp'); <-- save a good file, so is not a problem with the bmp going wrong... 
          i := i +1;
        ...

Offline

#2 2013-09-17 10:34:07

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: MormotReport is making black images in PDF

Instead you could use a TPdfImage object which has a CreateJpegDirect constructor.

Then you can do TPdfDocument.Canvas.DrawXObject

This should also mean that there's no need to uncompress the jpeg file.

Offline

#3 2013-09-17 14:09:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: MormotReport is making black images in PDF

Are you using the latest unstable version, e.g. from http://synopse.info/fossil/wiki?name=Downloads ?
You can have the latest files from last night at http://synopse.info/files/mORMotNightlyBuild.zip

Offline

Board footer

Powered by FluxBB