Add image to the top of a letter

  • Hi
    I am trying to add a logo to the letter head when a letter is issuesd as an attachment (pdf format). The PDFExport is working for the text but no image appears.
    What i am trying to do is add the image to the TWPCustomRtfEdit. Then export as usal

    Code
    img := TWPOImage.Create(aRte);
    img.LoadFromFile('LG_Massey.bpm');
    aRte.TextObjects.Insert(img);
    aRte.Refresh();
    pdfExport.Source := aRte;
    pdfExport.Print;

    Can you tell me how to get the image to appear at the top of a letter that is then saved as PDF?

    I have opened this image in MSPaint and copied and pasted it into a letter manually and can get it to save. But I need to do this in code.

    TIA

    Jeff

    • Offizieller Beitrag

    Hi,

    Instead of "Refresh" You need to call ReformatAll in this case.

    CPPosition := =; would move the cursor to the start.

    Is there a typo- 'LG_Massey.bpm' ?

    In general that works - You can test the insertion by saving the to a file and check there.

    Julian

  • Hi
    Working great now thanks.
    This is what I have ended up with.

    Code
    img := TWPOImage.Create(aRte);
             img.LoadFromFile(ExtractFilePath(Application.ExeName)+ 'LG_Massey.bmp');
             aRte.CPPosition := 0;
             aRte.InsertPar;
             aRte.CPPosition := 0;
             aRte.TextObjects.Insert(img);
    
    
             aRte.ReformatAll(false,false);