pratrick
Messages postés25Date d'inscriptionvendredi 7 mars 2003StatutMembreDernière intervention22 octobre 2010
-
26 juin 2010 à 23:45
Bacterius
Messages postés3792Date d'inscriptionsamedi 22 décembre 2007StatutMembreDernière intervention 3 juin 2016
-
28 juin 2010 à 06:28
Messieurs bonjour
J'ai tenté de mettre ce code mais sans succés
unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMan, RpRender, RpRenderPDF, RpDefine, RpBase, RpFiler,
StdCtrls, ComCtrls, shellapi, rpmemo,
ExtCtrls;
type
TForm11 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
StatusBar1: TStatusBar;
Memo1: TMemo;
RvNDRWriter1: TRvNDRWriter;
RvRenderPDF1: TRvRenderPDF;
OpenDialog1: TOpenDialog;
XPManifest1: TXPManifest;
FontDialog1: TFontDialog;
OpenDialog2: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure RvNDRWriter1Print(Sender: TObject);
private
reportdata: tmemorystream;
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form11: TForm11;
implementation
{$R *.dfm}
procedure TForm11.Button1Click(Sender: TObject);
begin
reportdata := tmemorystream.Create;
//Then we assign this data to report writer
RvNDRWriter1.Stream := reportdata;
//Execute the report
//////////////////////////////
//pour moi le probléme vient de cette endroit
RvNDRWriter1.Execute;
//j'ai l'impression qu'il n'arrive pas à //executé
//et donc creer un PDF vide
//////////////////////////////////////
rvrenderpdf1.PrintRender(reportdata, 'Sample.pdf');
//open newly created PDf file
ShellExecute(Handle, 'open',
'Sample.pdf', nil, nil, SW_SHOWNORMAL);
freeandnil(reportdata)
end;
procedure TForm11.RvNDRWriter1Print(Sender: TObject);
var memo:tmemobuf;
begin
memo:=tmemobuf.Create ;
memo.Memo :=memo1;
with (sender as tbasereport) do begin
SetFont('Arial', 15);
GotoXY(1, 1);
Print('Learn how to create PDF documents from Delphi');
end;
end;
end.
Quelqu'un pourrait t'il m'aider dans ma recherche pour comprendre mon erreur
d'avance merci
Bacterius
Messages postés3792Date d'inscriptionsamedi 22 décembre 2007StatutMembreDernière intervention 3 juin 201610 28 juin 2010 à 06:25
Salut,
bien que je ne connaisse pas rvRenderPDF, je vois bien que tu ne mets rien dans ton TMemoryStream. Tu le crée ... puis tu l'assigne directement au PDF. Donc evidemment que ça affiche rien puisque le stream est vide. Peut-être faudrait-il ouvrir le fichier PDF ? Tu seras plus à l'aise avec un TFileStream (qui est aussi un stream) :
reportdata := TFileStream.Create('monfichier', FMOPENREADWRITE);
rvRenderPDF1.Stream := reportdata; // ou TMemoryStream(reportdata) si besoin
...
reportdata.Free;
Bacterius
Messages postés3792Date d'inscriptionsamedi 22 décembre 2007StatutMembreDernière intervention 3 juin 201610 28 juin 2010 à 06:28
Ou alors j'ai peut-être mal compris l'utilité de ton code, mais le fait est que reportdata est vide. Je ne sais pas ce que le PDF d'arrivée doit contenir mais il faudrait mettre les données appropriées dans reportdata