Translatin some code from Fr2 to Fr3

edited 10:06PM in FastReport 3.0
I'm trying to translate the following code from Fr2 to Fr3
The code uses WPDF to save a fastreport output in PDF format

But i can't find (of course) the EMFPages property in FR3

thank you a lot for any help

Roberto

P.S. Congratulation for the new FR version. I like it !!

uses Windows, Classes, FR_Class, WPPDFR1, WPPDFR2;

procedure generate_pdf(report:Tfrreport;pdf_file:string);

implementation

procedure generate_pdf(report:Tfrreport;pdf_file:string);
Var
i: integer;
wpdf:TWPPDFPRINTER;
begin
wpdf:=TWPPDFPRINTER.create(nil);

try

wpdf.GraphicDriverMode:=wpdf.GraphicDriverMode + [wpsetcanvasresolution];

With report do
begin
if EMFPages.Count <> 0 then
begin
wPDF.filename:=pdf_file;

wPDF.BeginDoc;

for i := 0 to EMFPages.Count - 1 do
begin
EMFPages.Pages.Visible := True;

wPDF.StartPage(
MulDiv(EMFPages.pgwidth,72,72),
MulDiv(EMFPages.pgheight,72,72),
72, 72,0);


EMFPages.Draw(i, wPDF.canvas, Rect(0, 0, EMFPages.pgwidth,EMFPages.pgheight));

wPdf.EndPage;
end;

wPDF.EndDoc;
end;
end;

finally
wpdf.free;
end;
end;

Comments

  • edited 10:06PM
    Use TfrxReport.PreviewPages:

    procedure TfrxPreviewPages.DrawPage(Index: Integer; Canvas: TCanvas;
    ScaleX, ScaleY, OffsetX, OffsetY: Extended);


    var
    Page: TfrxReportPage;

    Page := frxReport1.PreviewPages.Page;
    { sizes are in Page.Width, Page.Height }
    frxReport1.PreviewPages.DrawPage(i, wPDF.canvas, 1, 1, 0, 0);
  • edited 10:06PM
    Thank you.

    It works fine.

    For who is interested in convert FR3 reports in PDF using wPDF this is the code that works for me:

    procedure fr3_2_pdf(report:Tfrxreport;pdf_file:string);
    Var
    i: integer;
    wpdf:TWPPDFPRINTER;
    Pg: TfrxReportPage;
    begin
    wpdf:=TWPPDFPRINTER.create(nil);

    try
    With report do
    begin
    if previewpages.Count <> 0 then
    begin
    wPDF.filename:=pdf_file;

    wPDF.BeginDoc;

    for i := 0 to previewpages.Count - 1 do
    begin
    Pg:=PreviewPages.Page;

    wPDF.StartPage(MulDiv(trunc(pg.width),72,72),
    MulDiv(trunc(pg.height),72,72),
    72, 72,0);

    PreviewPages.DrawPage(i, wPDF.canvas, 1, 1, 0, 0);

    wPdf.EndPage;
    end;

    wPDF.EndDoc;
    end;
    end;
    finally
    wpdf.free;
    end;
    end;
  • ManMan
    edited 10:06PM
    ;)
    Hi


    I'm New In Fast Report

    I Want To Translate FastReport 2.52 File To FastReport 3.0 File

    How Can I Make It If It Possiple.

    Man
  • edited 10:06PM
    Open the designer, File|Save as..., select "FR3 report" in the "file type" drop-down list.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.