Access Violation when calling Print

  • Hello

    I am receiving an access violation when the following line of code is executed.

    w := MulDiv(FSource.Memo._PaintPages[i].WidthTw,WPScreenPixelsPerInch,1440);

    This line is from the PrintPages procedure in the WPPDFWP unit.

    What I am doing is taking a TImage and inserting it into a TWPRichtext.

    Bitmap.LoadFromFile(FilePath);
    Image1.Picture.Assign(Bitmap);
    RichText.TextObjects.Insert(NewObject(Image1));

    I then assign my TWPRichtext to a TWPPDFExort

    PDFExport.Source := RichText;


    When I call print I get an access violation.

    PDFExport.Filename := (FilePath+cCo_Code+cTarget+'.pdf');
    PDFExport.BeginDoc;
    PDFExport.Print;
    PDFExport.EndDoc;

    Any ideas?

    I am using Delphi 7 with wptools 5. This did work using Wptools 4.

    Zo

  • Until Julian replies, let me throw a couple of things out there.

    First of all, have you checked what the value of the index i (with PaintPages) is at the point you get the AV? It will be interesting to see if it's a reasonable value or, my guess, -1 or something.

    Secondly, do you have any calls to Application.ProcessMessages in your code ANYWHERE that might be executed prior to the section of code that does the PDF printing? If so, remark the ProcessMessages call out and see if that makes a difference.

    Regards,
    richard diamond