Discussion:
Create PDF file
(too old to reply)
Bill C
2007-03-20 09:16:18 UTC
Permalink
G'day all,

Delphi 7 Pro, Word 2000, MSSQL server 7
My database prepares reports as Word docs (actually in RTF) for
printing and these can be saved to a local directory.

Using nothing more than Rave (ie no further software), I would
like to take this Word file and convert it to a PDF. Tip #96 in
Nevrona's Tips and Tricks suggests you can do this, but I think
there are code errors in their example. I certainly can't get it
to work. It would be good if this could be done in code,
without using the Rave visual designer.

As usual, everyone's guidance and suggestions are appreciated.
Cheers
Bill
Trevor Keegan
2007-03-21 06:05:42 UTC
Permalink
Hello Bill,

What is the problem that you are having?

If I look at tip #96, it is not converting a Word file into PDF, it is only
reporting directly into PDF file a stream....is this what you are wanting to
do?

Regards
Trevor Keegan
Bill C
2007-03-21 08:04:11 UTC
Permalink
Thanks for your reply Trevor,

Tip #96 does report to a stream, but the final line of code is
OutStream.SaveToFile('test.pdf');
The Tip comment is "In the example the PDF file is saved to file
as one of the last steps."

The problem I have is that the code doesn't run. I think there
are 2 errors (undeclared identifiers)
RvRenderPDF1.Engine := RvNDRWriter1;
RvRenderPDF1.Execute;
RvRenderPDF1 doesn't have a property "Engine" nor a function
"Execute" (I have a very limited understanding of Rave, but am
OK with Delphi)

I am looking to:
1. get a Word file from disk using
RichEdit1.LoadFromFile('WordFile.doc')
2. put it into a memory stream (RichEdit.SaveToStream(NdrStream)) then
3. save it as a PDF (using Tip #96 code).

Thanks for your further comments
Cheers
Bill
Post by Trevor Keegan
Hello Bill,
What is the problem that you are having?
If I look at tip #96, it is not converting a Word file into PDF, it is only
reporting directly into PDF file a stream....is this what you are wanting to
do?
Regards
Trevor Keegan
clacke
2007-03-21 19:05:37 UTC
Permalink
Bill,
Post by Bill C
Thanks for your reply Trevor,
Tip #96 does report to a stream, but the final line of code is
OutStream.SaveToFile('test.pdf');
The Tip comment is "In the example the PDF file is saved to file
as one of the last steps."
The problem I have is that the code doesn't run. I think there
are 2 errors (undeclared identifiers)
RvRenderPDF1.Engine := RvNDRWriter1;
RvRenderPDF1.Execute;
RvRenderPDF1 doesn't have a property "Engine" nor a function
"Execute" (I have a very limited understanding of Rave, but am
OK with Delphi)
1. get a Word file from disk using
RichEdit1.LoadFromFile('WordFile.doc')
2. put it into a memory stream (RichEdit.SaveToStream(NdrStream)) then
3. save it as a PDF (using Tip #96 code).
Thanks for your further comments
Cheers
Bill
Post by Trevor Keegan
Hello Bill,
What is the problem that you are having?
If I look at tip #96, it is not converting a Word file into PDF, it is only
reporting directly into PDF file a stream....is this what you are wanting to
do?
Regards
Trevor Keegan
You cannot produce a pdf starting from another output produced by Rave.
So, you could produce your report from scratch in pdf format.
Following a procedure you could copy to produce a pdf by code:

procedure CreatePDF(FileName: string);
var
tmpRvp: TRvProject;
tmpRvs: TRvSystem;
tmpRPdf: TRvRenderPDF;
begin
try
tmpRvp := TRvProject.Create(Self);
tmpRvs := TRvSystem.Create(Self);
tmpRPdf := TRvRenderPDF.Create(Self);
tmpRvp.Engine := tmpRvs;
tmpRvp.ProjectFile := 'C:\MyDirectory\project1.rav';
tmpRvs.DefaultDest := rdFile;
tmpRvs.DoNativeOutput := false;
tmpRvs.RenderObject := tmpRPdf;
tmpRvs.OutputFileName := FileName;
tmpRvs.SystemSetups := tmpRvs.SystemSetups - [ssAllowSetup];
tmpRvs.SystemOptions := [];
tmpRvp.Open;
tmpRvp.ExecuteReport('Report1');
tmpRvp.Close;
finally
tmpRvp.Free;
tmpRvs.Free;
tmpRPdf.Free;
end;
Bill C
2007-03-22 07:07:51 UTC
Permalink
"clacke",
But what (in general terms) is contained in Project1?

I already have a Word file on disk (created via Word automation
- not Rave).
My idea as indicated was as follows:
1. get the Word file from disk using
RichEdit1.LoadFromFile('WordFile.doc')
2. put it into a memory stream (RichEdit.SaveToStream(NdrStream)) then
3. save it as a PDF via Rave (using Tip #96 code).

Won't this work?


Cheers
Bill
Post by clacke
You cannot produce a pdf starting from another output produced by Rave.
So, you could produce your report from scratch in pdf format.
procedure CreatePDF(FileName: string);
var
tmpRvp: TRvProject;
tmpRvs: TRvSystem;
tmpRPdf: TRvRenderPDF;
begin
try
tmpRvp := TRvProject.Create(Self);
tmpRvs := TRvSystem.Create(Self);
tmpRPdf := TRvRenderPDF.Create(Self);
tmpRvp.Engine := tmpRvs;
tmpRvp.ProjectFile := 'C:\MyDirectory\project1.rav';
tmpRvs.DefaultDest := rdFile;
tmpRvs.DoNativeOutput := false;
tmpRvs.RenderObject := tmpRPdf;
tmpRvs.OutputFileName := FileName;
tmpRvs.SystemSetups := tmpRvs.SystemSetups - [ssAllowSetup];
tmpRvs.SystemOptions := [];
tmpRvp.Open;
tmpRvp.ExecuteReport('Report1');
tmpRvp.Close;
finally
tmpRvp.Free;
tmpRvs.Free;
tmpRPdf.Free;
end;
Eldon Lewis
2007-03-22 22:05:15 UTC
Permalink
Bill,
Post by Bill C
But what (in general terms) is contained in Project1?
I already have a Word file on disk (created via Word automation
- not Rave).
1. get the Word file from disk using
RichEdit1.LoadFromFile('WordFile.doc')
2. put it into a memory stream (RichEdit.SaveToStream(NdrStream)) then
3. save it as a PDF via Rave (using Tip #96 code).
Won't this work?
Cheers
Bill
If the WordFile.doc is an rtf file then it should work just fine because
Rave can import rtf. However, most .doc files are not rtf files and Rave
would not be able to make the conversion.

Eldon Lewis
Nevrona Designs

Eldon Lewis
2007-03-22 00:25:41 UTC
Permalink
Post by Bill C
The problem I have is that the code doesn't run. I think there
are 2 errors (undeclared identifiers)
RvRenderPDF1.Engine := RvNDRWriter1;
RvRenderPDF1.Execute;
RvRenderPDF1 doesn't have a property "Engine" nor a function
"Execute" (I have a very limited understanding of Rave, but am
OK with Delphi)
I have updated the tip and trick. The two statements above should reference
RvProject1 instead of RvRenderPdf1.

I apologize for the typos.

Eldon Lewis
Nevrona Designs
Bill C
2007-03-22 06:48:43 UTC
Permalink
G'day all,
Just received an email from Nevrona, as follows... (!)
"Bill,
I apologize for the typos in the tip and trick. I have now
corrected the error and the code that is out there now should
work just fine.
Best Regards,
Technical Support
Nevrona Designs"

Cheers
Bill
Post by Bill C
G'day all,
Delphi 7 Pro, Word 2000, MSSQL server 7
My database prepares reports as Word docs (actually in RTF) for
printing and these can be saved to a local directory.
Using nothing more than Rave (ie no further software), I would
like to take this Word file and convert it to a PDF. Tip #96 in
Nevrona's Tips and Tricks suggests you can do this, but I think
there are code errors in their example. I certainly can't get it
to work. It would be good if this could be done in code,
without using the Rave visual designer.
As usual, everyone's guidance and suggestions are appreciated.
Cheers
Bill
Loading...