I have created a Delphi DLL that passes in the a .rtf filename and the creates a .prf using WPPDFExport.
The DLL works great when run from a Test program that calls the dll but access violates when run from an DELPHI ISAPI dll running under IIS7
Access violation occurs on WPPDFExport.print.
I have the wPDF200A.dll in Syswow64 as well as the directory that the Isapi DLL is in.
Even though it fails, It does create a PDF file, but the .PDF it is missing the Image that is at the top of the RTF.
calling DLL from ISAPI DLL
function CreatePdf(Fname:shortstring):Boolean; StdCall; External 'rtf2pdf.dll';
rtf2pdf code
Function CreatePdf(infile:Shortstring):Boolean; stdcall;
var
Frm:TFrmMain;
fin :String;
begin
Frm := TFrmMain.Create(nil);
fin:=InFile;
trace('infile:'+fin);
Result:=Frm.BuildPDF(fin);
Trace('After BuildPdf');
Frm.free;
Trace('After Frm Free');
result:=true;
end;
exports
CreatePdf;
//------------------------------------------------ ----End of code
begin
end.
function TfrmMain.BuildPdf(infile:String):Boolean;
var
rtf :TWPRichText;
pdfexp :TWPPDFExport;
OutFile :string;
begin
trace('start');
Try
rtf:=TWPRichText.CreateDynamic;
PdfExp:=TWPPDFExport.Create(nil);
Rtf.LoadFromFile(infile);
WPDF_Start('xxx','yyy');
PdfExp.Source:=rtf;
rtf.ReformatAll(true);
Outfile:=StringReplace(infile,'.RTF','.PDF',[rfReplaceAll,RfIgnoreCase]);
PdfExp.Filename:=outfile;
trace('Before Print');
PdfExp.print; // access violates
trace('after Print');
Finally
pdfexp.Free;
rtf.Free;
trace('after free');
End;
end;