#1 2019-03-28 12:40:48

markus64
Member
Registered: 2019-03-28
Posts: 1

Problem with FloodFill and TPdfDocumentGDI

Hi all,

I'm new to SynPDF and evaluating it for a new project. It's a very nice component and it fills all my need (outlines, jpg/bmp/png, annotations, bookmarks) except for the FloodFill procedure.
I can't get it to work.

procedure TForm1.Button1Click(Sender: TObject);
var filename:string;
   lPdf:TPdfDocumentGDI;
   lPage:TPdfPage;
begin
   filename:='c:\temp\SynPDF.pdf';
   lPdf:=TPdfDocumentGDI.Create();
   try
      lPdf.ScreenLogPixels:=600;
      lPDF.DefaultPaperSize:=psA4;
      lPage:=lPDF.AddPage;

      lPDF.VCLCanvas.Pen.Color:=ClBlack;
      lPDF.VCLCanvas.Pen.Width:=1;
      lPDF.VCLCanvas.Pen.Style:=psSolid;
      lPDF.VCLCanvas.Pen.Mode:=pmCopy;
      lPDF.VCLCanvas.Brush.Color:=clYellow;
      lPDF.VCLCanvas.Brush.Style:=bsSolid;

      lPDF.VCLCanvas.MoveTo(400,400);
      lPDF.VCLCanvas.lineto(600,800);
      lPDF.VCLCanvas.lineto(200,800);
      lPDF.VCLCanvas.lineto(400,400);
      lPDF.VCLCanvas.FloodFill(500,700,ClBlack,fsBorder);

      lPdf.SaveToFile(filename);
   finally
      lPdf.Free;
   end;
   ShellExecute(Handle, nil, PChar(filename), nil, nil, SW_SHOWNORMAL);
end;

Anyone have a clue what I'm doing wrong in the code to get that area filled? The lines are drawn as expected.

Offline

#2 2019-03-28 17:23:35

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

Re: Problem with FloodFill and TPdfDocumentGDI

EMR_EXTFLOODFILL is indeed not supported yet in EnumEMFFunc().

It should be converted into E.Canvas.FillStroke call...

Offline

#3 2020-11-09 02:15:49

Klaus
Member
Registered: 2020-11-09
Posts: 2

Re: Problem with FloodFill and TPdfDocumentGDI

I have the same problem - Floodfill does nothing. I tried the FillRect method (having only rectangles to fill dynamically), but after a FillRect call, no other MoveTo followed by LineTo does produce any effect, whereas befor usage of FillRect, the drawn lines do appear correctly.

So, I tried to draw my grid first using MoveTo and LineTo sequences, which worked fine. But then, using FillRect to color the different rectangles appearantly override the rectangle borders when I display de PDF file with Acrobat reader (default resolution 47 %). Zoom into the page up to 800 % shows correct position of the colored rectangles, not overlapping any separation line.

So, my question is: how can I color an array type ordered sequence of rectangles (each of them may have a different color) ? I'm using SynPDF version 1.18, units directly integrated into a Delphi 6 Personal Edition DLL. I dont see any FillStroke method within VCLCanvas.

Last edited by Klaus (2020-11-09 08:53:34)

Offline

#4 2020-11-09 08:53:08

Klaus
Member
Registered: 2020-11-09
Posts: 2

Re: Problem with FloodFill and TPdfDocumentGDI

I found a Work-around... For each cell, i use the TextRec method to display a colored rectangle with a signe space as text, thus producing a pure color rectangle in the right place. After that, I trace all the required lines, around the table as well as the horizontal ane vertical lines. This way, the lines will show up, in the right places. And Zooming confirms the correct dimensins and positionning.

Offline

Board footer

Powered by FluxBB