#1 2011-10-06 08:52:41

Blamaster
Member
Registered: 2011-10-05
Posts: 3

DrawBMP and multiple BMP´s ?

Hello,

i have a little problem. I have 4 pages. If i draw a different BMP on each of the 4 pages the preview shows the pages correctly but if i save the pages as a pdf i have the same BMP on many pages.

Is there any solution to solve the problem ?

Thanks,
Yannic Wilkening

Offline

#2 2011-10-06 11:59:43

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

Re: DrawBMP and multiple BMP´s ?

I was not able to reproduce the issue with the current 1.15 revision of the library.
It just worked as expected.

Here is what I modified in the Unit1.pas unit of TestSQLite3Pages.dpr sample:

      // main content (automaticaly split on next pages)
      NewHalfLine;
      TextAlign := taJustified;
      s := 'This is some big text which must be justified on multiple lines. ';
      DrawText(s+s+s+s);
      NewLine;
      TextAlign := taLeft;
      DrawTitle(edt1.Text,true);
      for i := 1 to 10 do
        DrawText('This is some text '+IntToStr(i));
      NewLine;
      DrawBMP(Bmp,maxInt,50,'Some bitmap in the report');
      AddBookMark('bookmarkname');
      WordWrapLeftCols := true;
      AddColumns([10,20,50]);
      AddColumnHeaders(['#','Two','Three'],true,true);
      for i := 1 to 100 do
        DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'Some text here. '+s]);
      NewLine;
      // here I MODIFY the Bmp to create a 2nd one
      Bmp.Canvas.Pen.Color := clRed;
      Bmp.Canvas.MoveTo(0,0);
      Bmp.Canvas.LineTo(Bmp.Width,Bmp.Height);
      DrawBMP(Bmp,maxInt,50,'Some bitmap in the report (twice)');
      DrawTitle('This is your text',false,0,'','bookmarkname');
      DrawText(mmo1.Text);

So I guess there is something wrong in your code.

Are you using the VCLCanvas or the TPDFCanvas ? If you use TPDFCanvas, make sure you're  creating a new bitmap each time, with its own ID.

Offline

#3 2011-10-06 14:43:50

Blamaster
Member
Registered: 2011-10-05
Posts: 3

Re: DrawBMP and multiple BMP´s ?

Here is a short testcode:

procedure TForm1.btn1Click(Sender: TObject);
var
  i, y: integer;
  test: TRect;
  TestImage: TImage;
begin

  with TGDIPages.Create(self) do
  try
    BeginDoc;

    for y := 0 to 4 do
    begin

      DrawTitle(edt1.Text, true);
      for i := 1 to 10 do
        DrawText('This is some text ' + IntToStr(i));
      NewLine;

      try
        TestImage := TImage.Create(self);
        TestImage.Width := 500;
        TestImage.Height := 500;

        TestImage.Canvas.Pen.Color := clRed;
        TestImage.Canvas.MoveTo(0, y * 80);
        TestImage.Canvas.LineTo(TestImage.Width, y * 80);

        DrawBMP(TestImage.Picture.Bitmap, maxInt, RightMarginPos);
      finally
        TestImage.Free;
      end;

      NewPage;
    end;

    EndDoc;
    ExportPDF('test.pdf', true, true);
  finally
    Free;
  end;
end;

As you can see the pdf should include 5 pages with 5 different bmp´s. If i use this code i have  different bmp´s on page 1,2 and 3. 4 and 5 have the same bmp as page 2.

Here is my SqLite3Pages.pas

http://willyou.typewith.me/ro/r.JECHaT7GRujDFJ6H

I modified it a little bit but i have changed nothin with the DrawBmp handling.

Offline

#4 2011-10-06 19:00:41

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

Re: DrawBMP and multiple BMP´s ?

I don't know why, but the GetDIB Windows API call in TPdfDocument.CreateOrGetImage method did failed in unknown occasion...

I've fixed the issue in the following commit:
http://synopse.info/fossil/info/5d2f8fea00

Thanks for the feedback.

Offline

#5 2011-10-06 20:02:43

Blamaster
Member
Registered: 2011-10-05
Posts: 3

Re: DrawBMP and multiple BMP´s ?

Thanks,

works fine smile

Offline

Board footer

Powered by FluxBB