wpPDF Plus AV in TWPPDFExport.PrintPages

  • Hi
    We have just purchashed a single licence to wpPDF plus to allow us to evaluate it. But we have a show stopper problem. I have previously sent this to 'support@wptools.de' but have not had a reply. Can this forum help?

    I am trying to add PDF exporting to wpTools5 But I can not get it to run – I get an AV from WPPDFWP.TWPPDFExport.PrintPages (Line 235, "WPPDFWP.pas")
    This line is –
    // V2.60 - new way to read page size
    w := MulDiv(FSource.Memo._PaintPages[i].WidthTw,WPScreenPixelsPerInch,1440);

    I have added this code to our server side letter generation which is build on TWPCustomRtfEdit.

    Code
    procedure TLTGNEmailLetterIssue.SaveAsPDF(aRte : TWPCustomRtfEdit; aFileName : string);var   pdfExport : TWPPDFExport;begin   try      pdfExport := TWPPDFExport.Create(nil);      try         WPDF_Start(The confidential stuff you sent us );         pdfExport.Source := aRte;         pdfExport.Filename := aFileName;         //pdfExport.FontMode := wpEmbedTrueTypeFonts; // only do this if going to the printery not if emailing as attachment        // pdfExport.Encryption := [wpEncryptFile,wpEnablePrinting];           pdfExport.Print;    // this is line 430      finally         FreeAndNil(pdfExport);      end;      if not FileExists(aFileName) then         raise Exception.Create('Failed to save PDF file ' + aFileName);   except      on e: exception do      begin         e.Message := 'TLTGNEmailLetterIssue.SaveAsPDF' + #13#10 + e.Message;         raise;      end;   end;end;

    The stack dump on error is

    [009F70F5] WPPDFWP.TWPPDFExport.PrintPages (Line 235, "WPPDFWP.pas")
    [004049EE] System.@HandleFinally (Line 10065, "system.pas")
    [009F6FF3] WPPDFWP.TWPPDFExport.PrintPages (Line 216, "WPPDFWP.pas")
    [009F700A] WPPDFWP.TWPPDFExport.PrintPages (Line 218, "WPPDFWP.pas")
    [004041C7] System.TObject.NewInstance (Line 8360, "system.pas")
    [00402C1A] System.@GetMem (Line 2439, "system.pas")
    [009F3D83] WPPDFR1.TWPCustomPDFExport.SetFileName (Line 875, "WPPDFR1.pas")
    [009F6F2A] WPPDFWP.TWPPDFExport.Print (Line 181, "WPPDFWP.pas")
    [009FA3D7] UnitLTGNEmailLetterIssue.TLTGNEmailLetterIssue.SaveAsPDF (Line 430, "UnitLTGNEmailLetterIssue.pas")
    [009FA480] UnitLTGNEmailLetterIssue.TLTGNEmailLetterIssue.SaveAsPDF (Line 440, "UnitLTGNEmailLetterIssue.pas")
    [009FA0D8] UnitLTGNEmailLetterIssue.TLTGNEmailLetterIssue.extractAttachedLetters (Line 382, "UnitLTGNEmailLetterIssue.pas")
    [009F9253] UnitLTGNEmailLetterIssue.TLTGNEmailLetterIssue.SendEmailLetter (Line 152, "UnitLTGNEmailLetterIssue.pas")
    [009FDC1C] UnitDMLetterGenerator.TDMLetterGenerator.aaiIssueEmailLetterOnAction (Line 1138, "UnitDMLetterGenerator.pas")

    In debug I get to line 235 WPPDFWP.TWPPDFExport.PrintPages and inspect
    w := MulDiv(FSource.Memo._PaintPages[i].WidthTw,WPScreenPixelsPerInch,1440);
    I get something for FSource.Memo
    (nil, '', 0, nil, nil, 0, [], nil, [csInheritable], nil, $535EC70, 0, 0, 0, 0, [csCaptureMouse,csClickEvents,csSetCaption,csDoubleClicks], [], False, True, True, True, True, alNone, False, dmManual, False, bdLeftToRight, True, [akLeft..akTop], False, nil, $535F230, nil, -16777211, $535F258, 0, -12, nil, '', 0, (0, 0), (0, 0), [], False, True, dkDrag, doNoOrient, nil, 0, 0, 0, 0, 0, TCustomDockForm, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, htContext, '', 0, $535F27C, False, [], [], wpspCheckInInit, nil, nil, $535B5C0, nil, wpIsBody, wpraOnAllPages, '', '', '', [soAllStylesInCollection..soWriteObjectsAsRTFBinary], False, [], (100, False, False, False, False, False), nil, [], [], 0, [wpTableResizing,wpTableColumnResizing,wpObjectMoving..wpObjectDeletion,wpSpreadsheetCursorMovement,wpActivateUndo..wpActivateUndoHotkey,wpMoveCPOnPageUpDown], [], [], 'AUTO', 'AUTO', '', $5362340, nil, True, $5375568, False, 0, $53633A4, nil, 1252, False, False, 0, nil, nil, False, $535B5C0, $535B5C0, $535B5C0, False, False, False, False, 0, False, nil, $535B5C0, 0, 0, 0, 0, -1, 0, 0, '', (0, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), 0, False, False, False, False, 0, 0, [wpobjMergeField..wpobjHyperlink], $535F370, nil, nil, nil, $535F3DC, 0, False, False, False, ((0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0)), (0, 0, 0, 0, (0, 0), (0, 0))), 0, 0, 0.5, 0.5, wpNoFrameLine, 0, 0, 0, 0, nil, False, False, False, nil, nil, nil, nil, nil, nil, $535B5C0, nil, nil, nil, nil, False, 0, 0, 0, 0, 1440, 2000, 96, -16777211, -16777200, 0, 0, 15908791, nil, nil, False, 144, 144, 144, 144, 200, 100, 1, $535B5C0, wpAutoZoomOff, 1, 1, wplayFullLayout, True, 0, 0, 0, 0, [], 0, 0, False, 600, 600, [], 1, 1, 0, False, [], [], 0, False, -1, $5362088, $536209C, 0, 0, 0, 0, nil, 0, 0, 0, 0, False, False, False, F

    In wpdf_inc.inc I have

    Code
    // 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}

    What am I doing wrong?

    • Offizieller Beitrag

    Hi,

    I would assume the text is not formatted.

    If you load the RTF and want to export it right away you must call WPRichText1.ReformatAll(false, false).

    The text is usually formatted in idle phases of the app - if there is none, call ReformatAll.

    If the editor was created dynamically use a TWPCustomRTFEdit class instead and create it using the constructoir CreateDynamic.

    Regards,

    Julian