#1 Re: PDF Engine » Vertical & Horizontal problem when shade every other row » 2015-11-27 07:10:00

I've recently upgraded to FastReport VCL 5. To apply the workaround there the method TfrxBrushFill.Draw must be patched.

procedure TfrxBrushFill.Draw(ACanvas: TCanvas; X, Y, X1, Y1: Integer; ScaleX,
  ScaleY: Extended);
var
  br, oldbr: HBRUSH;
  OldPStyle: TPenStyle;
begin
  with ACanvas do
  begin
    Brush.Style := Style;
//    FFill.Draw(FCanvas, FX, FY, FX1, FY1, FScaleX, FScaleY);
    if FBackColor <> clNone then
    begin
      Brush.Color := FBackColor;
      Brush.Style := bsSolid;
      // this is a workaround for export with SynPDF
      // +++ original code +++
      // FillRect(Rect(X, Y, X1, Y1));
      // --- original code ---
      // +++ patched code +++
      OldPStyle := Pen.Style;
      Pen.Style := psClear;
      Rectangle(X, Y, X1+1, Y1+1);
      Pen.Style := OldPStyle;
      // --- patched code ---
    end;
    if Style <> bsSolid then
    begin
      { Brush.Style := xxx does not work for some printers }
      { Brush.Style := xxx does not work for some printers }
{$IFDEF FPC}
{$warning LCL: CreateHatchBrush() NOT IMPLEMENTED YET !}
      {TODO: CreateHatchBrush() implementation}
      br := LCLIntf.CreateSolidBrush(ColorToRGB(FForeColor));
{$ELSE}
      br := CreateHatchBrush(Integer(Style) - 2, ColorToRGB(FForeColor));
{$ENDIF}
      oldbr := SelectObject(Handle, br);
      SetBkMode(Handle,TRANSPARENT);
      OldPStyle := Pen.Style;
      Pen.Style := psClear;
      Rectangle(X, Y, X1 + 1, Y1 + 1);
      SelectObject(Handle, oldbr);
      DeleteObject(br);
      Pen.Style := OldPStyle;
    end;
  end;
end;

#2 Re: PDF Engine » Vertical & Horizontal problem when shade every other row » 2014-04-01 15:51:15

I had similar problems with the export from FastReports. If there is a background color in a TfrxView object with a frame, then the frame lines are not drawn correctly.

As a workaround I patched TfrxView.DrawBackground, replacing FillRect(Rect(FX, FY, FX1, FY1)) by Rectangle(FX, FY, FX1+1, FY1+1)

procedure TfrxView.DrawBackground;
var
  br, oldbr: HBRUSH;
  OldPenStyle: TPenStyle;
begin
  with FCanvas do
  begin
    Brush.Style := FBrushStyle;
    if FColor <> clNone then
    begin
      Brush.Color := FColor;
      Brush.Style := bsSolid;
      // +++ original code +++
      // FillRect(Rect(FX, FY, FX1, FY1));
      // --- original code ---
      // +++ patched code +++
      OldPenStyle := Pen.Style;
      Pen.Style := psClear;
      Rectangle(FX, FY, FX1+1, FY1+1);
      Pen.Style := OldPenStyle;
      // --- patched code ---
    end;
    if FBrushStyle <> bsSolid then
    begin
      { Brush.Style := xxx does not work for some printers }
      {$IFDEF FPC}
      {$warning LCL: CreateHatchBrush() NOT IMPLEMENTED YET !}
      {TODO: CreateHatchBrush() implementation}
      br := LCLIntf.CreateSolidBrush(ColorToRGB(Self.Frame.Color));
      {$ELSE}
      br := CreateHatchBrush(Integer(FBrushStyle) - 2, ColorToRGB(Frame.Color));
      {$ENDIF}
      oldbr := SelectObject(Handle, br);
      Rectangle(FX, FY, FX1 + 1, FY1 + 1);
      SelectObject(Handle, oldbr);
      DeleteObject(br);
    end;
  end;
end;

#3 PDF Engine » EMF picture leads to syntax error: invalid content stream state » 2014-04-01 15:41:16

andreas
Replies: 0

If I try to render a simple EMF vector graphic (using PdfDocument.Canvas.RenderMetaFile) I get a pdf with an "invalid content stream state" (by Acrobat Preflight PDF syntax check).

After some testing I found out that this happens when the operator rg (set in TPdfCanvas.SetRGBFillColor) or the operator d (set in TPdfCanvas.SetDash) is included. When I generate the pdf without these operators no syntax errors are reported.

Any ideas how to fix (or avoid) these syntax errors?

Board footer

Powered by FluxBB