TWPPDFExport not working when used in ISAPI DLL

  • 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;

    Einmal editiert, zuletzt von billyb (2. März 2021 um 18:22)

  • We have an existing license for WPTools 7. Will this work or do we need to purchase another license?

    If we need to purchase, can you send me the info to my email I registered with for this forumn?

    Bill B

  • I downloaded the demo for wPDFControl /wRTF2PDF-TextDynamic Server


    I have tried to create a test app in delphi 10.4.1 using code below and get message that demo has expired.

    I imported the object and created an activex component unit wPDF_X01_TLB

    I get the error " This demo of wPDFControl /wRTF2PDF-TextDynamic Server is expired"

    I assume i pass in blank values for license info for demo dll.


    What am I doing wrong.

    procedure TForm2.Button3Click(Sender: TObject);

    var

    pdf :TpdfControl;

    begin

    Pdf:=TpdfControl.Create(nil);

    pdf.StartEngine('C:\DRIOVCL\source\wPDFControl\DLL\wPDFControlDemo04w.dll','','',0);

    pdf.BeginDoc('E:\Users\info\Desktop\boe3.pdf',0);

    PDF.ExecIntCommand(1000, 0);

    PDF.ExecStrCommand(1002, 'E:\Users\info\Desktop\boe3.rtf');

    PDF.ExecIntCommand(1100, 0);

    PDF.EndDoc();

    end;

  • Thank you for the feedback.

    We just purchased the wpdf server and also the upgrade to wptools 9

    we are using delphi 10.4.1

    I want to be able to use with wptools 7, but I get this version is not licensed only 3 pages with print error.

    I modifed wp_inc per the instructions and rebuilt wptools 7, but how do I get the wpdfexport to work without DLL?

    I do not have SOURCE for the new wpdf server, was it supposed to be included?

    Where are the .dcu's that I would use so that I do not use the DLL?

    Do I need to copy anything for the new WPDF folder to somewhere else?

    Do I need to have a lib path to somewhere in the new WPdf folder?

    I am at a loss as to how to proceed.

    • Offizieller Beitrag

    In the delivery mail there are the strings "name" and "code".

    Both value have to be passed to the global function WPDF_Start(name,code).

    After that the engine is licensed and will not show the message. This valid for wPDF Standard and wPDF Plus or Server.

    wPDF PLUS installs the DCU files for most Delphi editions.

    Please add the compiler conditional WPDFPLUS to your project to make sure it pulls in the DCU file. If it does not filnd the files, please add the path (for the correct delphi edition = DX14 for Delphi 10.4) to the library path.

    You find the library path when you go to the IDE, Tools/Options and there under Language/Delphi.

  • I have installed the wpdf server version in new wptools 9 and it works great as a vcl app witth no external DLL's. But when I try in in my web ISAPI app (dll) I get access violation. on WPPDFExport.Print

    Access violation at address 0215937B in module 'PdsWebServer.dll'. Write of address 00000000

    It does create a .pdf file, but it is missing the image at the top of the document. Is there other units I need to include when using as in a .DLL?

    My uses clause includes "WPRTEDefs, WPCTRMemo, WPCTRRich, WPPDFR1, WPPDFWP, WPUtil"

    Is there something I am missing.

    IN WPDF_INC.INC


    {$DEFINE WPDF4}

    {$DEFINE WPDF3} // does this need to be turned off?

    {$DEFINE WPDFPLUS}


    // This define MUST be enabled. It switches the use of the wPDF DLL on

    // If you have wPDF PLUS or the InterNet server edition please

    // disable this $define

    {$IFNDEF WPDFPLUS}

    {$DEFINE INTWPSWITCH} // wPDF Standard: ON - wPDF PLUS: OFF

    {$ENDIF}

    // Activate this to compile WPDF2

    {.$DEFINE WPDF_VER2} // does this need to be turned on (wdf says it is version 4)


    Function Rtf2Pdf2(InFile,OutFile :String):Boolean;

    var

    WPRichText :TWPRichText;

    WPPDFExport: TWPPDFExport;

    begin

    Result:=True;

    Trace('Rtf2Pdf2 start');

    WPRichText:= TWPRichText.CreateDynamic;

    WPPDFExport:= TWPPDFExport.Create(nil);

    WPPDFExport.Source := WPRichText;

    try

    WPDF_Start('xxxxx','yyy@zzzz'); // using new license code for wpdf server version

    WPRichText.LoadFromFile(infile);

    WPPDFExport.FileName := outfile;

    WPRichText.ReformatAll(true);

    Trace('Rtf2Pdf2 Before Print');

    WPPDFExport.Print;

    Trace('Rtf2Pdf2 after Print');

    finally

    WPRichText.Free;

    WPPDFExport.Free;

    end;

    end;

    3 Mal editiert, zuletzt von billyb (21. März 2021 um 22:48) aus folgendem Grund: Forgot to put in access violation error

    • Offizieller Beitrag

    Hi,

    WPDF3 and WPDF4 uses the same technology to capture the graphic data. So both defines are turned on.

    On a server environment the use of WPRichText :TWPRichText is not recommended since TWPRichText contains references to UI elements. The correct components is TWPCustomRTFEdit. Do not include unit WPCTRRich.

    To make the process threadsave it is also required to have one TWPToolEnvironment object per thread:

    The problem with the Image could be caused by GDI+.

    You can deactivate the use of GDI+ by adding {$DEFINE NOGDIPLUS} to WPINC.INC. See the effect of this in unit WPObj_Image.pas.

  • Thank you it is now working.

    At first it still access violated after the changes you detailed, until I added the {$DEFINE NOGDIPLUS} to WPINC.INC.

    Is there a downside to not using GDI+ ? I will be using the TWPPDFExport in a windows VCL application as well as the IIS server dll.

    Also in the readme.txt document for the WPSpell v2 it says to get the latest dictionary

    To download dictionaries please use this link:

    http://www.wpcubed.com/products/wpspell/index.html

    This link goes to page not found

    The english.dct in the wpspell DCT folder is dated 2005 is there a newer one I should use?

    Again, thank you for your assistance.