Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

problems with ndBlankReport and DeviceType = PDF

edited July 2009 in General
I wish to use rb 11 to email a pdf report. In the tppreport control, I have
created rtf field in the detail band. At runtime I load this rtf field and
I am able to comfirm this action is sucessful. The no data behavior is set
to ndblankreport, and devicetype is set to dtpdf. The code fails on
creation of the pdf. I have tried many variations but without sucess;
either the code jams or pdf attachment (blank!) is emailed. Is a datapipe
and some data required to suceed???





TppSMTPPlugIn.RegisterClass(TppSMTPIndy);
TppEmail(ppReport.Email).SMTP.OnEmailError:=EmailErrorEvent;
TppEmail(ppReport.Email).SMTP.OnStatusChange:=EmailStatusEvent;
With ppReport Do
Begin
ResetDevices;
NoDataBehaviors:=[ndBlankReport];
DeviceType:=dtPDF;
If FileExists(ProgramDirectory+'\Document.Pdf') Then
DeleteFile(ProgramDirectory+'\Document.Pdf');
TextFileName:=ProgramDirectory+'\Document.Pdf';
AllowPrintToFile:=True; {very necessary}
ShowPrintDialog:=False; {very necessary}
End;
With ppReport.PDFSettings Do
Begin
OpenPDFFile:=False;
OptimizeImageExport:=True;
If (TLicense.FieldValues['FirstName']<>Null) And
(TLicense.FieldValues['FirstName']<>'') Then
Author:=TLicense.FieldValues['FirstName']+' '+
TLicense.FieldValues['LastName']
Else
Author:=TLicense.FieldValues['LastName'];
If TLetter.FieldValues['DocumentSubject']<>Null Then
Title:=TLetter.FieldValues['DocumentSubject']
Else
Title:='Report';
End;
MyStreamM:=TMemoryStream.Create;
MyStreamM.Clear;
RVEdit.SaveRTFToStream(MyStreamM,False);
MyStreamM.Position:=0;
ppRichText1.RichTextStream.Clear;
ppRichText1.LoadFromRTFStream(MyStreamM);
MyStreamM.Free;


{ ... this didn't work either

lPDFDevice:=TppPDFDevice.Create(Nil);
If FOutputStream=Nil Then
FOutputStream:=TMemoryStream.Create
Else
FOutputStream.Clear;
Try
lPDFDevice.PDFSettings:=ppReport.PDFSettings;
lPDFDevice.OutputStream:=FOutputStream; // assign output stream
lPDFDevice.Publisher:=ppReport.Publisher;
// generate the report
ppReport.PrintToDevices;
Finally
lPDFDevice.Free;
MyStreamM.Free;
FOutputStream.Free;
End;
}




With ppReport.EmailSettings Do
Begin
Enabled:=True;
Subject:=ppReport.PDFSettings.Title;
FromAddress:=PracticeEmailAddress;
FromName:=PracticeName;
ReplyTo:=PracticeEmailAddress;
Recipients.Clear;
Recipients.Add(SendTo);
PreviewInEmailClient:=False;
ShowEmailDialog:=True;
ShowCancelDialog:=True;
Attachments.Clear;
HostAddress:=PracticeSMTP;
UserName:=PracticeAccountName;
PassWord:=PracticePassword;
End;
ELoop:=False;
ppReport.SendMail;

thanks for your help

Barry Noble

Comments

This discussion has been closed.