WPCubed Product Support

problem with ArcTo(...)

Hi Support,

thank you for the update.

I tested and the result is now as expected.

But I still found a problem when I am not using BeginPath/EndPath/StrokeAndFillPath.

When I comment out these three lines, I still have the old problem.

procedure DrawShape( Canvas: TCanvas );
begin

  Canvas.Brush.Color := clLime;
  Canvas.Brush.Style := bsSolid;
  Canvas.Pen.Width   := 5;
  Canvas.Pen.Color   := clGrayText;

  Canvas.MoveTo( 1000 , 500 );

  // BeginPath( Canvas.Handle );
  SetArcDirection( Canvas.Handle, AD_COUNTERCLOCKWISE );
  Canvas.ArcTo( 1500 , 500 , 500 , 1500 , 1000 , 500 , 500 , 1000 );

  Canvas.LineTo( 550 , 1050 );

  SetArcDirection( Canvas.Handle, AD_CLOCKWISE );
  Canvas.ArcTo( 550 , 1550 , 1550 , 550 , 550 , 1050 , 1050 , 550 );

  Canvas.LineTo( 1000 , 500 );

  // EndPath(Canvas.Handle);
  // StrokeAndFillPath(Canvas.Handle);

end;

Here is the result: 🖼 wpdf-ArcTo-problem3.jpg (www.ahnenblatt.de)

So ArcTo is not working in every situation.

Perhaps you can fix this also.

Thanks, Dirk

#11 ♥ 0
8.8k Views 5 links 2 users read 4 min
wpsupport

Hello, this took a while, sorry.

The new version wPDF V5.2.0 include updated code for ArcTo which renders your example file.

#10 ♥ 0

Sounds good. Thanks.

I hope, I have not wait too long ... ;-)

  • Dirk
#9 ♥ 0
wpsupport

I was able to reproduce this using the EMF and by setting the flag it improved.

I am able to reproduce the problem using your example code and fixed it for next build of wPDF V5

#8 ♥ 0

Again sample code and the result.

procedure DrawShape( Canvas: TCanvas );
begin

  Canvas.Brush.Color := clLime;
  Canvas.Brush.Style := bsSolid;
  Canvas.Pen.Width   := 5;
  Canvas.Pen.Color   := clGrayText;

  Canvas.MoveTo( 1000 , 500 );

  BeginPath( Canvas.Handle );
  SetArcDirection( Canvas.Handle, AD_COUNTERCLOCKWISE );
  Canvas.ArcTo( 1500 , 500 , 500 , 1500 , 1000 , 500 , 500 , 1000 );

  Canvas.LineTo( 550 , 1050 );

  SetArcDirection( Canvas.Handle, AD_CLOCKWISE );
  Canvas.ArcTo( 550 , 1550 , 1550 , 550 , 550 , 1050 , 1050 , 550 );

  Canvas.LineTo( 1000 , 500 );

  EndPath(Canvas.Handle);
  StrokeAndFillPath(Canvas.Handle);

end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  ...
  DrawShape( WPPDFPrinter1.Canvas );
  ...

end;

procedure TForm1.Button2Click(Sender: TObject);
var
  Canvas: TCanvas;
begin

  DrawShape( PaintBox1.Canvas );

end;

And this is the result (left PaintBox - right pdf file):

🖼 wpdf-ArcTo-problem2.jpg (www.ahnenblatt.de)

How can I get the same result in pdf?

  • Dirk
#7 ♥ 0

Any news in my case?

I still need a solution to get the same shapes in pdf as on screen (the "chaotic" one - the simple one was only for demonstration).

  1. Could you reproduce the situation? You never confirmed that.
  2. Is it a bug in wpdf? Only in 4.8x or also in 5.x?
  3. Which version have you used to get a correct pdf? In my case SetArcDirection changed nothing - I am using 4.8x - but also tried the 5.x trial.
  4. What should I do next?
  5. Can you confirm that an update to 5.x would help? 5.x trial did no change.
  6. Where could I find the changelog of wpdf to check if something was changed?
  7. Dirk
#6 ♥ 0

Yes, I use SetArcDirection twice with second parameter AD_COUNTERCLOCKWISE and AD_CLOCKWISE to get a full shape (piece of donut).

That's how I got the "chaotic" shapes in pdf file.

Shouldn't the shapes be the same on screen and in pdf?

  • Dirk
#5 ♥ 0
wpsupport

Please try to add a call to

SetArcDirection(Canvas.Handle, 2 )

to make sure it uses the correct direction. In my testes that fixes the line at the start.

>> What does "Blocked image" mean?

It simply does not load the image from your server when loading the page. It is possible to click on the link though.

#4 ♥ 0
wpsupport

Can you sende me an EMF to try this in my demo. Thats easy: wPDF.DebugMode := true

If you need to fill your path you need a BeginPath/EndPath bracket - did you try?

#2 ♥ 0

I have problems with Canvas.ArcTo( ... ) function. On screen everything is fine. With wPDF I always get a vertical line from top of the canvas to the starting point of the arc in the final pdf file. I tried with wPDF 4.81, 4.82 and 5 trial and always got the same result.

It seems that y value of actual pen position is ignored (or assumed to be zero) when drawing the arc.

Arc( ... ) is not an alternative, because it's not working with StrokeAndFillPath in my case.

Is it a bug? Any known workaround?

Best regards,

Dirk

Here is part of my source code and a screenshot of the result:

  WPPDFPrinter1.BeginDoc;

  WPPDFPrinter1.StartPage( GetDeviceCaps( Printer.Handle , PHYSICALWIDTH ) ,
													 GetDeviceCaps( Printer.Handle , PHYSICALHEIGHT ) ,
													 GetDeviceCaps( Printer.Handle , LOGPIXELSX ) ,
													 GetDeviceCaps( Printer.Handle , LOGPIXELSY ) , 0 );

  Canvas := WPPDFPrinter1.Canvas;

  Canvas.Pen.Width := 5;

  Canvas.Pen.Color := clBlack;
  Canvas.MoveTo( 1000 , 500 );
  Canvas.ArcTo( 1500 , 500 , 500 , 1500 , 1000 , 500 , 500 , 1000 );

  Canvas.Pen.Color := clRed;
  Canvas.MoveTo( 1100 , 550 );
  Canvas.LineTo( 1050 , 550 );

  Canvas.Pen.Color := clBlack;
  Canvas.ArcTo( 1550 , 550 , 550 , 1550 , 1050 , 550 , 550 , 1050 );

  WPPDFPrinter1.EndPage;

  WPPDFPrinter1.EndDoc;
 

🖼 wpdf-ArcTo-problem.jpg (www.ahnenblatt.de)

#1 ♥ 0