#1 2015-11-20 12:16:00

DoctorJ
Member
Registered: 2015-11-19
Posts: 1

[Delphi 7][FastReport 2.5][SynPdf] Export FastReport To PDF

Hi,

I'm trying to use this to produce interesting library pdf, in my case I'm trying to get a pdf from a report made with FastReport 2.5.
I downloaded the latest version of SynPdf (1.18) and use Delphi 7.

The following code works but I can not use the property [GeneratePDF15File] also can not understand why I do not find [tpExactTextCharacterPositining].

Also during the installation of the component I had to comment on the part of crypting otherwise could not compile the package.

Thank you very much to those who want to help me out.

unit UFreePdf;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, FR_Class, SynPdf;

type
  TForm1 = class(TForm)
    frReport1: TfrReport;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
    frReport1.LoadFromFile('D:\Temp\Test.frf');
    frReport1.ShowReport;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i,w,h:integer;
    EMF: TMetafile;
    EMFCanvas: TMetafileCanvas;
    PageInfo: PfrPageInfo;
    vpdf : TPdfDocumentGDI;
    OutDC: HDC;
    LogX, LogY : Extended;
begin
    OutDC := Canvas.Handle;
    LogX := GetDeviceCaps(OutDC, LOGPIXELSX);
    LogY := GetDeviceCaps(OutDC, LOGPIXELSY);

    frReport1.LoadFromFile('D:\Vari\Medusa\RepProva.frf');
    frReport1.ShowProgress:=false;
    frReport1.PrepareReport;

    vpdf := TPdfDocumentGDI.Create;
//    vpdf.GeneratePDF15File :=true;
    vpdf.CompressionMethod := cmNone;

    vPdf.DefaultPaperSize := psA4; // setup for standard 8.5x11 Letter
    vPdf.ScreenLogPixels := 72;

    for i:=0 to frReport1.EMFPages.Count-1 do
     begin
        PageInfo :=frReport1.EMFPages[i];
        EMF := TMetafile.Create;
        w:=trunc(PageInfo.prninfo.pgw/logX*vpdf.ScreenLogPixels);
        h:=trunc(PageInfo.prninfo.pgh/logY*vpdf.ScreenLogPixels);
        EMF.Width := w;
        EMF.Height := h;
        EMFCanvas := TMetafileCanvas.Create(EMF, 0);
        PageInfo.Visible := True;
        frReport1.EMFPages.Draw(i, EMFCanvas,
        Rect(0, 0, w, h));
        vpdf.AddPage;
        EMFCanvas.Free;
//        vPdf.Canvas.RenderMetaFile(emf, 1, 0, 0, tpExactTextCharacterPositining);
        vPdf.Canvas.RenderMetaFile(emf, 1, 0, 0, vpdf.UseSetTextJustification);
        EMF.Free;
     end;

    vpdf.SaveToFile('D:\Temp\Test.pdf');
    vpdf.free;
end;

end.

Offline

Board footer

Powered by FluxBB