convert metafile to pdf using freereport
Hi,
could someone help me?
I'm almost getting a report convert to pdf but there is inconsistency with the size of the generated PDF page.
routine figure 1:
Here I subtract 250 units to display all records. (250 were based on trial and error)
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH-250)); //here
routine figure 2:
this statement were shown only 80% of records
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH));
area of 3 images show an area that is still unfilled, resulting in incorrect page report with about the report displayed in the preview freepreport.
my routine:
procedure TForm1.SpeedButton6Click(Sender: TObject);
var i:integer;
EMF: TMetafile;
EMFCanvas: TMetafileCanvas;
PageInfo: PfrPageInfo;
vpdf : TPdfDocumentGDI;
begin
frReport1.LoadFromFile('C:\Program Files (x86)\Delphi7SE\Testes\FreeReport\Simples\TESTE.frf');
frReport1.ShowProgress:=false;
frReport1.PrepareReport;
vpdf := TPdfDocumentGDI.Create;
vpdf.GeneratePDF15File:=true;
vpdf.CompressionMethod := cmNone;
for i:=0 to frReport1.EMFPages.Count-1 do begin
PageInfo :=frReport1.EMFPages;
EMF := TMetafile.Create;
EMF.Width := PageInfo.pgWidth;
EMF.Height := PageInfo.pgHeight;
EMFCanvas := TMetafileCanvas.Create(EMF, 0);
PageInfo.Visible := True;
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH));
{ frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH - 250 ));
}
vpdf.AddPage;
EMFCanvas.Free;
vpdf.VCLCanvas.Draw(0,0,EMF);
EMF.Free;
end;
vpdf.SaveToFile('C:\Users\BetoVG\Documents\teste.pdf');
vpdf.free;
ShellExecute(Handle, nil, PChar('C:\Users\BetoVG\Documents\teste.pdf'), nil, nil, SW_SHOWNORMAL);
end;
thanks
could someone help me?
I'm almost getting a report convert to pdf but there is inconsistency with the size of the generated PDF page.
routine figure 1:
Here I subtract 250 units to display all records. (250 were based on trial and error)
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH-250)); //here
routine figure 2:
this statement were shown only 80% of records
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH));
area of 3 images show an area that is still unfilled, resulting in incorrect page report with about the report displayed in the preview freepreport.
my routine:
procedure TForm1.SpeedButton6Click(Sender: TObject);
var i:integer;
EMF: TMetafile;
EMFCanvas: TMetafileCanvas;
PageInfo: PfrPageInfo;
vpdf : TPdfDocumentGDI;
begin
frReport1.LoadFromFile('C:\Program Files (x86)\Delphi7SE\Testes\FreeReport\Simples\TESTE.frf');
frReport1.ShowProgress:=false;
frReport1.PrepareReport;
vpdf := TPdfDocumentGDI.Create;
vpdf.GeneratePDF15File:=true;
vpdf.CompressionMethod := cmNone;
for i:=0 to frReport1.EMFPages.Count-1 do begin
PageInfo :=frReport1.EMFPages;
EMF := TMetafile.Create;
EMF.Width := PageInfo.pgWidth;
EMF.Height := PageInfo.pgHeight;
EMFCanvas := TMetafileCanvas.Create(EMF, 0);
PageInfo.Visible := True;
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH));
{ frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.PgW, PageInfo.PrnInfo.PgH - 250 ));
}
vpdf.AddPage;
EMFCanvas.Free;
vpdf.VCLCanvas.Draw(0,0,EMF);
EMF.Free;
end;
vpdf.SaveToFile('C:\Users\BetoVG\Documents\teste.pdf');
vpdf.free;
ShellExecute(Handle, nil, PChar('C:\Users\BetoVG\Documents\teste.pdf'), nil, nil, SW_SHOWNORMAL);
end;
thanks
Comments
procedure TForm1.SpeedButton6Click(Sender: TObject);
var i,w,h:integer;
EMF: TMetafile;
EMFCanvas: TMetafileCanvas;
PageInfo: PfrPageInfo;
vpdf : TPdfDocumentGDI;
OutDC: HDC;
begin
OutDC := Canvas.Handle;
LogX := GetDeviceCaps(OutDC, LOGPIXELSX);
LogY := GetDeviceCaps(OutDC, LOGPIXELSY);
PDFEscx :=strtofloat(edit1.text);
PDFEscy :=strtofloat(edit1.text);
frReport1.LoadFromFile('C:\Program Files (x86)\Delphi7SE\Testes\FreeReport\Simples\TESTE.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;
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);
EMF.Free;
end;
vpdf.SaveToFile('C:\Users\BetoVG\Documents\teste.pdf');
vpdf.free;
ShellExecute(Handle, nil, PChar('C:\Users\BetoVG\Documents\teste.pdf'), nil, nil, SW_SHOWNORMAL);
end;