Beiträge von dirkil

    I implemented an email client that displays emails in HTML format. I had the problem that all images were displayed except GIFs. I had to experiment a bit to find a solution.

    This is how I do it now (for Delphi XE2):

    In WPObjImage.pas I changed two things:

    Original:
    {-$DEFINE GIFIMG}

    My version:
    {$DEFINE GIFIMG}

    Original:
    {$IFDEF GIFIMG}, {$IFDEF DEL2007ANDUP}gifimg{$ELSE}gifimage{$ENDIF}{$ENDIF}

    My version:
    {$IFDEF GIFIMG}, {$IFDEF DEL2007ANDUP}Vcl.Imaging.GIFImg{$ELSE}gifimage{$ENDIF}{$ENDIF}

    I am afraid I still don't get it. Hier is my code:


    This at least doesn't show the merge field name anymore (thanks to ClearSelection) but still the table is appended below the merge field and does not replace the field itself.

    I assume it's either because I call "AppendNewTable" or I use ActivePar. I don't want to use the AddTable method because I want to create the table row by row in a loop.

    I would really appreciate if you could give me a few lines of code that show how you would implement OnGetTextToInsert.

    Regards,
    Dirk.

    I tried that already but it doesn't work. Setting this property makes the red << >> markers disappear but not the field name.

    I also tried ShowMergeFieldNames:=false which sounded like the right parameter but the fields names are still shown.

    So, still the question is: how to make the field name disappear?

    I would like to replace a mail merge field with a table. I do it like that:

    In

    Code
    OnGetTextToInsert(Sender: TObject; const inspname: String; const Contents: TWPMMInsertTextContents; var Done: Boolean)


    I use Contents.MergePar.AppendNewTable() and so on.

    This basically inserts the table but above the table the name of the merge field is visible. It seems that it left the paragraph with the mail merge field untouched and instead it appended a new paragraph and added the table to that new paragraph.

    I would rather like the table inside the paragraph where the merge field resides. I couldn't find an "InsertNewTable" instead of an "AppendNewTable". But maybe my whole approach is wrong.

    Can you please explain to me how I can insert a table in a mail merge?

    Many thanks in advance,

    Dirk.

    I am using TdxLayoutControl from DevExpress and set its property DoubleBuffered to true to avoid flickering.

    When I place a TWPRichText on it and click in it, the cursor is shown for a split second and then gone. When I set DoubleBuffered to false, everything works fine.

    This problem is not correlated to the DevExpress control, since the same happens when I use a TPanel instead of the DevExpress control.

    I think this is a bug in TWPRichText and if you don't disagree it should be fixed.

    In my document I have a left page margin of 6cm so that I have quite some space to add custom things on the left side. I want to use this space to add text boxes and position them to fixed positions.

    This works well as long as I have simple text in the boxes. But I also want to add an image to the box and that fails. I used TWPORTFTextBox.AddSubImage for that purpose but I can't see the image. Here is my code:

    Can you please correct my code or tell me another approach to add an image to a text box?

    Many thanks in advance,
    Dirk.

    In my documents I use quite a few tables that have text before and afterwards. I would like to indent the tables so they don't start left-aligned with the text. For example it should look like that:


    Can you please explain to me how I can achieve that?

    How could I achieve that the table itself is right-aligned (not the text in the table but the whole table)?

    Many thanks in advance,
    Dirk.

    Hi Julian!

    We store certain fixed graphics that are used for mail merging as BLOBs in the database. Our mail merge procedure is as follows:

    1. User chooses data source and mail merge template.
    2. Application executes mail merge and displays result in RTF editor.
    3. User can make manual changes to the text.
    4. Final document is saved in database.

    My problem is that I want to save the final document without the pictures that were mail merged. They are static and can be re-put in whenever it is needed. I don't want to waste space in the database.

    Therefore my question: how can I remove the mail merged graphics from the final RTF document? I know the names of the mail merge fields. Can I still reference the fields in the merged document? If so, can I then do the merge again but this time specify an empty object?

    How would you do it?

    Regards,

    Dirk.

    I want to append the contents of an RTF file to my exported page. Unfortunately I am getting an access violation. The code I use to export is like that:

    Code
    procedure TForm1.isdPdfExpBTClick(Sender: TObject);var  lFile: String;  lTmpRtf: TWPRichText;begin  if nameTF.Text <> '' then    lFile := 'datenabo_'+nameTF.Text+'.pdf'  else    lFile := 'datenabo.pdf';  lTmpRtf := TWPRichText.Create(nil);  lTmpRtf.LoadFromFile('AGB.rtf', false);  isdPdfExp.Filename := lFile;  try    try      WPDF_Start('xxx','xxx');      isdPdfExp.BeginDoc;      isdPdfexp.Source := isdDoc;      isdPdfExp.Print;      isdPdfexp.Source := lTmpRtf;      isdPdfExp.Print;      isdPdfExp.EndDoc;      ShellExecute(handle, 'open', PCHAR(lFile), nil, nil, sw_show );    except on E: Exception do      MessageDlg(E.Message, mtError, [mbOK], 0);    end;  finally    lTmpRtf.Free;  end;end;

    The access violation happens in unit WPPDFWP on line 252:

    Code
    // V2.60 - new way to read page size
              w := MulDiv(FSource.Memo._PaintPages[i].WidthTw,WPScreenPixelsPerInch,1440); // it crashes here
              h := MulDiv(FSource.Memo._PaintPages[i].HeightTw,WPScreenPixelsPerInch,1440);
              if (w=0) or (h=0) then
              begin
               w := Round( FSource.Memo.PaintPageWidth[i] / FSource.Memo.CurrentZooming );
               h := Round( FSource.Memo.PaintPageHeight[i] / FSource.Memo.CurrentZooming );
              end;

    Unless I am doing something wrong I reckon this is a bug.

    Any help is very much appreciated!

    Regards,
    Dirk.

    There were two things I had to change to make it work:

    1. The images I wanted to include were PNG images. By browsing through this forum I found out that I need a special package that makes PNG images work. I chose GraphicEx.

    2. The URL was a bit cryptic and didn't have the image extension at the end. So I figure that TWPRichText couldn't determine what kind of graphic handler to work with. So I changed the url so that it has a standard extension and then it worked.

    There is only one thing left that is not correct but I will post that in another thread: the PNG image has transparent areas and these areas are displayed as black which looks ugly since my background is white. Maybe I need to set some property in GraphicEx but I haven't found anything yet.

    Regards,
    Dirk.

    I tried to display an Indy 10 Message in a TWPRichText. I followed the documentation and the sample but it doesn't seem to work. It displays the text correctly but where the actual images should be placed there are only red squares.

    You can download a sample program that illustrates the wrong behaviour. You can download it from here: http://www.niftybits.de/downloads/HttpImageBug.zip

    Just run it and you'll see the red squares.

    The images are read in correctly; if I save them in the OnRequestHTTPImage to disk they are correct.

    For a test I also tried: instead of loading the images from the mail l loaded them from disk directly. This had the same wrong result.

    It has probably to do that TextObject.Width and .Height are 0 after:

    Code
    TextObject.LoadObjFromStream(URL, lStream);

    I cannot debug it further since I don't have the source code. Therefore I would be very happy if Julian could have a look at it.

    Regards,
    Dirk.

    I am not sure if I understand that correctly. When I read the mail it is already in a TIdMessage object. I then iterate over the attachments and take the text from the Body property. Here is the function:

    Where do you mean I could use the format string "HTML-utf8" ?

    I try to display an Email Text taken from an Indy TIdMessage. UTF-8 encoded texts are not displayed correctly. I think the problem is that the charset is not part of the HTML of the message text but rather inside the TIdMeesage.

    So if there was a method I could set the charset of the TWPRichText it probably would be fine. Maybe I overlooked it but I only found DefaultAttr.SetFontCharSet but this takes an Integer and I found no further description.

    Maybe someone can help me out, please.

    Regards,
    Dirk.

    Here are the details of my message I would like to display:


    Content-Type: text/html ; charset="utf-8"
    Content-Transfer-Encoding: quoted-printable

    <html><head><style type=3D"text/css"><!-- DIV {margin:0px;} --></style=
    ></head><body><div style=3D"font-family:times new roman,new york,times=
    ,serif;font-size:12pt"><div>Sehr geehrte Damen und Herren,<br><br>ich =
    m=C3=B6chte gerne <span style=3D"font-weight: bold;">10 Lizenzen</span=
    > bestellen.<br><br>Vielen Dank!<br><br>Gerd Gerdes<br></div></div><br=
    >


    </body></html>