Merge Field Markers

  • With Delphi 2009, WPTools 6.05.7 and wPDF 3.55

    If I save a document in WPRichText component that contains merged fields and then create a pdf file using the code below, the merge field markers are displayed in the pdf document. Is there a mechanism to prevent the display of these markers?

    tempRTFPathAndName := tempFilePath + adsTablePtLetters.FieldByName('FileName').AsString;

    tempPDFPathAndName := tempRTFPathAndName;
    tempPDFPathAndName := Copy(tempPDFPathAndName, 1, Length(tempPDFPathAndName) - 3);
    tempPDFPathAndName := tempPDFPathAndName + 'pdf';

    tempRTFEdit := TWPCustomRTFEdit.CreateDynamic;
    tempWPPDFExport:= TWPPDFExport.Create(nil);

    try
    begin
    with tempWPPDFExport do
    begin
    Filename := tempPDFPathAndName;
    Source := tempRTFEdit;
    FontMode := wpUseTrueTypeFonts;
    CidFontMode := wpCIDOff;
    PDFAMode := wpdfaOff;
    CompressStreamMethod := wpCompressNone;
    AutoLaunch := False; // Do not show when completed
    end;

    tempRTFEdit.LoadFromFile(tempRTFPathAndName,true,'AUTO');
    tempRTFEdit.ReformatAll(true,false);
    tempWPPDFExport.Print;
    end
    except
    begin
    MessageDlg('A pdf file was unable to be created from the ' + tempRTFPathAndName + ' file.',
    mtError, [mbOK], 0);
    tempContinue := False;
    end;

    if tempWPPDFExport.Printing then
    begin
    tempWPPDFExport.EndDoc;
    end;

    tempWPPDFExport.Free;
    tempRTFEdit.Free;
    Screen.Cursor := crDefault;
    end;

    • Offizieller Beitrag
    Zitat von jredoc

    If I save a document in WPRichText component that contains merged fields and then create a pdf file using the code below, the merge field markers are displayed in the pdf document. Is there a mechanism to prevent the display of these markers?

    When you create the PDF from a TWPRIchText use

    WPRichText1.InsertPoints.Hidden := true


    the fields can be permanently deleted at save time using

    SaveToFile( filename, 'RTF-nomergefields' )

  • What is the solution if I am using a dynamically created CustomRTFEdit component which has no insertpoints property?

    tempRTFEdit := TWPCustomRTFEdit.CreateDynamic;
    tempWPPDFExport:= TWPPDFExport.Create(nil);

    try
    begin
    with tempWPPDFExport do
    begin
    Filename := tempPDFPathAndName;
    Source := tempRTFEdit;
    FontMode := wpUseTrueTypeFonts;
    CidFontMode := wpCIDOff;
    PDFAMode := wpdfaOff;
    CompressStreamMethod := wpCompressNone;
    AutoLaunch := False; // Do not show when completed
    end;

    tempRTFEdit.LoadFromFile(tempRTFPathAndName,true,'AUTO');
    tempRTFEdit.ReformatAll(true,false);
    tempWPPDFExport.Print;

    TIA

    John

    • Offizieller Beitrag

    Hi,

    I am writing from a notebook currently, was sloppy

    TWPCustomRTFEdit also has InsertPointAttr and the others:

    Code
    property InsertPointAttr: TCharacterAttrTags read GetInsertPointAttr write SetInsertPointAttr stored IsTextAttrStored;
        property HyperlinkTextAttr: TCharacterAttrTags read GetHyperlinkTextAttr write SetHyperlinkTextAttr stored IsTextAttrStored;
        property BookmarkTextAttr: TCharacterAttrTags read GetBookmarkTextAttr write SetBookmarkTextAttr stored IsTextAttrStored;
        property SPANObjectTextAttr: TCharacterAttrTags read GetSPANObjectTextAttr write SetSPANObjectTextAttr stored IsTextAttrStored;
        property HiddenTextAttr: TCharacterAttr read GetHiddenTextAttr write SetHiddenTextAttr stored IsTextAttrStored;
        property AutomaticTextAttr: TCharacterAttr read GetAutomaticTextAttr write SetAutomaticTextAttr stored IsTextAttrStored;
        property ProtectedTextAttr: TCharacterAttr read GetProtectedTextAttr write SetProtectedTextAttr stored IsTextAttrStored;
        property FieldObjectTextAttr: TCharacterAttr read GetFieldObjectTextAttr write SetFieldObjectTextAttr stored IsTextAttrStored;

    also see: http://www.wptools.com/manuals/wp5man…reate_field.htm

    Regards,
    Julian Ziersch

  • Hi Julian,

    Zitat von wpsupport

    WPRichText1.InsertPoints.Hidden := true

    SaveToFile( filename, 'RTF-nomergefields' )

    Which method do you suggest when using TDBWPRichText? I want to destroy the mergefields on posting the record.

    I have to get rid of the mergefield markers because they show up on printing with FastReport.

    best wishes,
    Wolfgang