RTF Image Data Not Copied Between TWPRichText components

  • Hello,

    We have noticed RTF data containing images created in version 6.03 does not copy the image data when using TWPRichText.AsString to read the rtf data, when read using version 6.06. RTF data created in version 6.06 does not produce the same issue.

    We have tested this with 6.25, which does appear to fix the issue. However, we are several months away from using 6.25+ in a production version.

    Is there a workaround that can be applied for 6.06? I do have a complete example available if needed.

    Thank you

    • Offizieller Beitrag

    Please check the setting of the WriteObject mode.
    It should be set to wobRTF.

    This is what happens in the 3 years since V6.06.

    16.10.2012 - WPTools 6.27''
    * some additions to the PRO edition for XE3


    26.9.2012 - WPTools 6.27'
    * The PRO Version now supports Delphi XE3


    3.8.2012 - WPTools 6.27
    - fix for wrong display of tables with header and footer rows. Sometimes both were painted without any data.
    + to load old Hiedit templates as RTF code use the formatstring -HiEditFields. This will create merge fields for ALL fields.
    - NL sign was not shown right after CTRL+ENTER was pressed (requires ShowNL)
    - fix for rangecheck exception with paintpages array
    - fix for footer and page mirror
    - doubleclick word selection now stops at NL
    - Workaround for Windows Spooler problems - some images would get lost
    - sections use footer and header of previous section, not general
    - ASetBorder did change all border types


    12.3.2012 - WPTools 6.25.4
    * allows changing of column width in redonly editors. Can be switchoed off in EditOptions or set
    compiler define TOTALREADONLY
    + wpDisableSelectAll in EditOptionsEx2
    * changed reformat/repaint after Undo/Redo
    - pro and premium: Due to a problem with precompiler cursoir selection did not work correctly


    8.3.2012 - WPTools 6.25.3'
    - borders for paragraphs with multiple lines were not drawn correctly
    - change in DBWPRich.pas to use LoadFromString instead of Text
    - fix possible range check error
    - change in WPTbar.pas to use different default for BevelOuter
    - change in WPIOHTML to use default charattr of paragraph is a paragraph is empty


    9.2.2012 - WPTools 6.25.2
    * new 2-pass painting triggers CustomPaint event only on second loop (when the text is painted)
    * changed protection of empty paragraph to WPTools 5 way
    + inside of the OnPrepareImageForSaving event it is now possible to set Writer.CurrentImageName
    to the name of the file which should be saved. This is only useful if ObjRef = nil and so no ObjRef.Filename can be set.
    + TParagraph.GetSubText now has optional parameter to disable the object reference char codes #1, #2 and #3
    * HTML writer ignores #13 codes when writing the text.
    * additional savety code in HTML writer
    * HTML reader sets image width and height to contents, (if possible)
    * HTML reader: changes UTF8 handling for UTF8Sequence=1
    * HTML reader does not stop on \0 anymore
    * HTML writer writes img tag also for empty images IF a name is provided in event PrepareImageforSaving
    * HTML reader does not add space at end anymore
    - the UNICODE reader uses attribute of current paragraph. This is important for consistent
    behaviour between ANSI and UNICODE version
    - when writing HTML background color is not set to white when shading is 0. 0 is treated as default value.
    - image align center and right now works in HTML
    - fix an endless loop when image was too large
    - improvement of table border drawing
    - improvement for right align in table cells
    + numbering will be used when wpFormatAsWebpage was set in AsWebpage


    10.1.2012 - WPTools 6.25
    + HTML reader reads cell heighs
    - RTF writer writes background color easier to understand by Word
    * improved XML reader/writer (unit WPIOXml1)
    * improved word wise cursor movement when fields are used
    + new "paint attributes" mode.
    Use WPRichText1.BrushStart to select this mode.
    - dashes were not painted using the current font color
    - some stability improvements


    7.11.2011 - WPTools 6.22
    + procedure TParagraph.CellSelectionAdd;
    + procedure CellSelectionRemove;
    + EditOptionsEx2: wpCellMultiSelect - allows multiselection in tables when CTRL is pressed
    + improved XML import/export (unit WPIOXML1.PAS)
    - some smaller bugs fixed


    3.11.2011 - WPTools 6.21.2
    - fix problem with TWPToolButton
    - improved HTML writer to write parameters in ""
    - improved display of arabic text


    24.10.2011 - WPTools 6.21.1
    - fix problem when painting insertpoints after tab stops. They were painted two times.
    - fix in XML and HTML writer. Close <div> tags when extracting text from fields


    19.10.2011 - WPTools 6.21
    + CodeLocate can now also accessed in non-visual TWPRTFDataCollection and not just TWPCustomRtfEdit
    + CodeSelect can now also accessed in non-visual TWPRTFDataCollection and not just TWPCustomRtfEdit
    + TWPRTFDataCollection.CodeLocatePair( FormatName : String; var spar, epar : TParagraph; var spos, epos, : Integer ) :Integer;
    - solves problem with integrated Bin64 decoder
    + DeleteField now has optional "Contents" parameter to delete a certain field with contents
    + the text writer now understand the option -softlinebreaks to create a \n at the end of
    every line. In fact all soft line breaks will be handled like the #10 code.
    + CodeLoadSaveEmbeddedText - load or save text in fields, bookmarks, hyperlinks
    + the regular save and load methods (LoadFromFile, SaveToFile) can now access text wrapped by paired objects.
    specify the fieldname in the format string, i.e. "f:name=RTF" to save or load the contents of the field "name".
    + There is an overloaded LoadFromString which expects a WideString as parameter (Delphi 6+)
    - The Setup named the Delphi 2009 files "Delphi 2005" due to a typo. (Delphi 2005 units are not included anymore)
    - fix probable range check error in WPRTEDEFS


    13.10.2011 - WPTools 6.20
    + completely new setup procedure. The PRO and Premium releases don't include object files which makes them much smaller.
    * compiled new WPTools 6 Reference (CHM file)
    * Delphi XE2: several small changes to improve theming support
    * Delphi XE2: several small changes to provide compatibilty to 64bit compiler (requires WPTools PRO)
    + new demo developed with Delphi XE2, showcases actions, splitscreen, simulated MDI and property dialogs (Demos\XE2\WPWord)
    + wpDeleteAtEOFRemovesSpaceAfter in EditOptionsEx2
    - TextObjectsGetList did not work
    * WPRuler uses Delphi XE2 VCL Theme plus
    * added defaults to properties TWPRichText
    - change in RTF reader to let section inherit the default layout, not the current page layout
    - fix of problem with table borders when also PageMirror was used.
    * change to DeleteMarkedChar. It now has additional parameter DeleteEmptyParAndTables : Boolean
    * change in unit WPWordConv to handle RTF as DOC files if they do not start with "{\rtf"
    * updated border dialog TWPParagraphBorderDlgEx
    * updated border drawing code - now supports dotted lines with wider lines.
    * modified method DeleteColumn
    * modified WPT reading code to repair table width which were negative
    + improved image rendering code for transparent (PNG) images. They will be drawn transparently
    also when scaled and also in high resolution rendering mode.
    + new code to draw dotted lines which also supports wider lines
    + new function WPReplaceTokens (unit WPUtils.PAS). It is a ReplaceTokens function to be used
    on a TWPRTFDataCollection, not TWPRichText
    - WPPremium - fix problem when there were too columns
    * MergeText now restores before Merge Cursor position and selection (except for cell selection)
    * resizing a table column does not move the cursor to the nearby cell anymore
    * different frame line when resizing columns and rows
    + InsertColumn now also works if wpAllowSplitOfCombinedCellsOnly was used in EditOptionsEx
    + new event OnPaintTextFrameRect let you paint background and borders for text frames,
    i.e. the text body or, with WPTools Premium, custom frames.
    + WPPREMIUM: In OnMeasureTextPage it is possible to set columns for certain pages.
    Using PageInfo.colflags=1 it is possible to activate a line between the columns
    It is also possible to add custom frames using PageInfo.rtfpage.AddFrameRect.
    + new ViewOptionEx: wpHideParBordersBeforAndAfterPageBreaks
    + improved paint routine now avoids clipping of characters which were overlapping their bounding box,
    such as italic letters or "f".
    The improvement is especially visible when selecting text or using character background colors
    + WPPREMIUM: it is now possible to print a line between columns using wpShowColumnCenterLine in ViewOptionsEx
    + With WPTools Premium it is now possible to print a line between certain colums -
    use par.ASet(WPAT_COLFLAGS, WPCOLUM_LINE);
    + paragraph styles can now contain border definion for paragraphs
    + TWPTextObjList now has a IndexOfSource function and a Source[] string array to access the objects
    * revised code to draw double borders - always draws twou lines on screen even when zoomed
    * improved saving of numbering attributes with styles
    * style dialog can now apply number level even if style does not have numbering yet.
    * revised wpNoEditOutsideTable - was not checked for keyboard input
    * fix problem with - - - - - at end of line
    - fix problem with spell-as-you go after hyperlinks
    - fix problem with page numbers in sections when tables were spanning pages
    - fix problem with right aligned negative numbers in merge fields
    * automatic text attribute was not inherited to tables inserted in fields
    * images with mode "under text " can now be also clicked at positiones where there is no text.
    - WPLngCtr now defines DONT_OVERRIDE_COM, that fixes the IDE problem with DevExpress Toolbar controls


    18.7.2011 - WPTools 6.16.2
    * ObjectMode wpobjPositionAtCenter can be used to aligh character based images to the center line. (Other RTF reader will not understand this feature)
    * some changes to prepare 64bit compatibility (requires WPTools 6 PRO)

    7.7.2011 - WPTools 6.16.1
    * change to avoid flickering when doing auto scroll
    * message strings are now loaded from resource strings
    - modified DBCS support for RTF reader
    * outerborder action now works for sinle cells and paragraphs


    15.6.2011 - WPTools 6.16
    + Many improvements to new Border Dialog.
    It is now possible to apply borders and colors to odd and even rows only.
    * RTF reader defines symbol IGNORE_AUTOWIDTH_TBL. This disable the Word2010 auto width columns which are not read
    correctly. Reason: Word 2010 seem to always add an empty column to the end.
    + using WPRichText1.Caret.Blink:=true it is possible to activate the blinking caret (0.5sec interval).
    * updated actions to apply inner and outer borders to selected cells
    * update to ExSymbolDialog, Tab and Table dialog
    - improved WPTOOLS reader to read and apply outline properties to current outline setting (unless wpLoadDoesNotOverride is used)
    - wpsec_ResetPageNumber flag is now saved in WPTOOLS format
    * tripple click in margin selects paragraph
    + double click in margin selects current cell
    + tripple click in margin selects current row
    - change for PaintEngine and TWPRichTextLabel to not shrink tables which are small enough to fit the page
    This solves a problem with dissapearing text in WPRichTextLabel
    - fix selection problem when several images were linked to same paragraph
    - when moving images the Z order will not be reset
    - HTML Writer: A style with name "DIV" will be added to the style sheet to save the default font
    - HTML Writer: BaseFont tag will now be written with font size (requires -writebasefont option)
    - improved display of character background color for fields and other special code
    - Saving a style sheet did not work with Unicode Compiler


    8.5.2011 - WPTools 6.15
    * updated border painting
    * updated Inner/Outer Border Action
    * new object sizing routine lets the user make the size larger than the page
    - update in WPTools reader to overwrite outline styles when loading tzhe same group


    9.3.2011 - WPTools 6.14.6
    * change in format routine to fix problem when a nested table cell caused a page break.


    14.12.2010 - WPTools 6.14
    * fix for SetAsString code (Unicode Delphi)
    * several fixes and updates in editor
    * WPTools Premium: $define DONT_AUTOENTER_TEXTBOXES in WPINC.INC to switch of the behavior,
    that when editing a textbox the user can click on any other and edit that.


    22.9.2010 - WPTools 6.13.3
    * WPCtrMemo.PAS now defines TEXT_IS_UNICODE fro Delphi 2009 and later. Now the property Text and SelText reads and writes unicode strigs
    * change in RTF reader to read ANSI characters in the range 128..255
    * Tables and rows can now be hidden. (TParagraph.Hidden)
    * The Lines property now supports unicode strings (Delphi 2009 and later)
    + HTML reader and writer now use the entitly &shy; as soft hyphen


    27.8.2010 - WPTools 6.13.2a
    + new ViewOptionEx wpUnderlineWebLinks. If active links like http://www.wptools.de will be drawn using the attributes for hyperlinks
    The HyperlinkCursor will be selected and the hyperlink event will be triggered
    * other fixes in RTF engine
    - Memo._OverrideCharset was not set to -1

    27.7.2010 - WPTools 6.13.1
    + WPRichText1.Memo.ColorGridLines can be used to change the color of the grid lines (ViewOptions)


    23.7.2010 - WPTools 6.13
    * several improvements of editor
    * improvement to RTF writer to when writing table cells
    * improved right aligned text
    * fixed problem with line heights of lines which are empty except for new line character


    22.6.2010 - WPTools 6.12.1b
    - fix for problem when pressing Accent + Backspace
    - fix for WPReporter to assign default attribute to destination
    - fix for WPReporter to move images when converting templates


    18.6.2010 - WPTools 6.12.1a
    * the new border dialog now reads the current border attributes from table cells, tables or selections
    - Premium: fix problem when loading columns which started on first line
    - fix in wpfUseKerning mode (FormatOptionsEx2) - it did not work as expected with some texts
    (We recommend to use wpfUseKerning - it produces better print quality on screen)
    * Pasting of HTML now works better
    - fix for right tabs when also borders were used


    13.6.2010 - WPTools 6.12
    + all new, powerful yet intuitive Border dialog.
    The border dialog can modify a range of selected cells, columns, rows, tables and also only
    modify certain properties while leaving the others unchanged.
    You need to activate the compiler symbol NEWBORDER to use it by default
    + new method: procedure SetBorderProperties(Inner, Outer: TWPTextStyle;
    ApplyMode : TWPParagraphBordApply;
    Mode : TWPUpdateBorderProperties =
    [wpSetBorderFlags, wpSetBorderType, wpSetBorderWidth, wpSetBorderColor, wpSetParColor, wpSetParShading]);
    This method is mainly used by the new border dialog.
    + new flags in ViewOptionsEx:
    wpShowCurrentCellAsSelected, // Displays current cell to be selected. Disables current selection
    wpShowCurrentRowAsSelected, // Displays current table row to be selected. Disables current selection
    wpShowCurrentTableAsSelected // Displays current table to be selected. Disables current selection
    + new property YOffsetNormal to defined an upper border for normal and wordwrap view.
    * feature Header.MarginMirror changed to work like MS Word
    new flag: wpMarginMirrorBookPrint in FormatOptionsEx2 to enable the previous logic
    * workaround for MouseWheel UP beeing triggered too often (10 mms check)
    + ClipboardOption wpcoDontPasteHTML to disable HTML pasting completely (avoid problems with firefox)
    + it is now possible to load base64 embedded JPEGs from HTML
    * it is now possible to change width of tables which exceed right margin
    - fix bug in HTML writer for lists in table cells
    - fix in RTF writer to write character colors also for text which is using a character style
    - fix: numbering was not always updated
    - fix: better use fonts in certain RTF files written by MS Word
    + Update to WPLanguageControl to make Localization easier to use. Only< this code is not required:

    procedure TForm1.WPLanguageControl1Loaded(Sender: TObject);
    begin
    WPLangInterface := TWPLocalizationInterface.Create(WPLanguageControl1);
    WPLocalizeAllStrings;
    end;


    6.5.2010 - WPTools 6.11.2
    * improvement to border rendering
    * improvement to XML unit WPIOXML1 (Premium)

    5.5.2010 - WPTools 6.11.1
    + ConvertTableToText now supports option to also handle soft line breaks
    - fix problems with underlines at end of line
    - fix problem when loading hyperlinks in RTF
    - fix problem when saving attributes to XML (WPTools Premium)
    - fix problem with text rendering
    - fix problem with tables which habe header row and pages with different header margin


    19.4.2010 - WPTools 6.11
    + EditOptionEx: wpRowMultiSelect
    + new event: OnInternPaintPar
    + new event: RTFDataCollection AfterApplyUndoObject


    14.4.2010 - WPTools 6.10.6
    * fields are now passed as unicode strings to PDF exporter
    * Delphi 2010/2009 import has been improved to load unicode values which are stroed in fields.


    5.4.2010 - WPTools 6.10.5
    + flag: wpDontExtendSelectionToRightMargin. Do not extend selection to end of line
    + wpInvertActiveRow in ViewOptionsEx
    - some fixes for Delphi 2009 and Delphi 2010
    - fix for section support
    - WPTools premium: Fix for images in text boxes
    - workwaround to load RTF which use emfblib for pngblib


    28.2.2010 - WPTools 6.10
    - improve word left/right movement to skip hidden text
    - improve http load of images
    - improve support for numbering
    - improve saving of character style attributes


    11.2.2010 - WPTools 6.09.1
    + LoadFromString now has a "WithClear" parameter
    - fix in RTF reader to better load files which do not define codepage
    - fix in paint routine to solve a rare lockup
    - fix in format routine to improve section support


    6.2.2010 - WPTools 6.09.1
    - fix of problem in save routine when footnotes were used (WPTools premium)
    - fix in HTML writer
    - Image optiions now have a Rotation property which allows 90, 180 and 270 setting.
    - HTML reader and writer now support different colors for left,right,top, bottom lines

    1.2.2010 - WPTools 6.09
    - HTML writer will write 8 hard spaces for TAB stops at the start of a paragraph
    - HTML writer will write page information only if -PageInfo was used in format string
    - fix problem with left aligned text and image wrap around (wrong alignment)
    - fix problem with sometimes duplicated images in PDF export
    - fix problem with black rectangle in first line under Windows 7, 64 bit
    - Improvment to RTF reader to ignore section properties which are not followed by \sect


    14.12.2009 - WPTools 6.08
    - graphics are resized to fill text area
    - fixed problems in numbering
    - fixed problem with one word paragraphs in justified paragraphs
    - other improvements in editor

    27.10.2009 - WPTools 6.07
    - fixed one leaking TList per TWPRichText
    * improved layout of most important dialogs
    * improved extended insert symbol dialog
    - fix in RTF reader to load sections and header+footer written by Word 2003
    - don't add unwanted cell padding when loading table cells
    - fix in WPTools reader to read custom number styles
    - if paragraph styles use number styles the indent defined in the style has priority over numberstyle
    - LabelDef now also works for one row and one column
    - better handling of mousewheel event
    - fix for tabs in tables
    + GIF animation (requires GifImage) library (not threaded)
    to use it You need to set ViewOption wpUseOwnDoubleBuffer and call
    the method RefreshAniImages using a timer object.
    - fix problem when sections were used with LabeDef.Active = true
    * change in HTML writer to close <b> tags before paragraph end