Editor displays RTF as a plain text

  • I have a project that uses WPTools 5. A programmatically generated raw RTF code is loaded into editor and displays in WYSIWYG mode.

    MemoryFormat:= fmRichText; WP.TextLoadFormat:= 'AUTO';

    After upgrading to 6th version the content displays as a plain text like this:
    ==============
    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil
    ==============

    1) What should I do to restore a component functionality?
    2) Where can I get a PDF documention for version 6? The installation package I was provided with doesn't contain it/

  • Thank you, AsString really allows to load a raw RTF code but there is a lot of misformatted text elements (fonts, tables, margins) now in document and it looks awful.

    Is there any way to switch engine into version 5 compatible mode or I must redo all my text generators source code to comply with WPTools 6 requirements?

    • Offizieller Beitrag

    Hi,

    Are You sure You used WPTools 5 before - when You speak of "MemoryFormat" I would rather expect that was V4. There is not so much difference between V5 and V6 and V6 PRO can be in fact be compiled as V5 (Disable Compiler symbol WP6) - but from Version 4 to Version 5 there is a big step.

    But it loads fonts and margins correctly and in a Word style manner.

    You didn't post an example so it is a bit hard to tell more. Best would be to send example file to support.

    Julian

  • Yes, I was wrong about previously used version, it is not 5 but 4.11d

    This is how document looked before migration to 6th version


    and this is how it looks now


    1. Incorrect font display in table title
    2. Incorrect table cells size
    3. No page number in a header
    4. Incorrect paper size/appearance in component window

  • You will need to mail the file to support.

    Sent via e-mail.
    It is identical in both cases but looks different in 4.11d version it has been originally create for and in WPTools 6.

    Einmal editiert, zuletzt von cps (23. Juni 2010 um 17:28)

  • Yes, the document on a link is unreadable with external editors but this is exactly an S string that is loaded into TWPRichText component and worked with older versions fine.
    ===========
    WPText.Text:= S;
    AddFooterHeader(WPText);
    WPText.ReformatAll();
    WPText.Show();
    ===========


    In case an RTF document is created in usual way with WPTools means (AddTable, InputString) it also look different and it is not design time issues because page orientation, font size and margins are defined programmatically at runtime like this:
    ===========
    LayoutMode:= TWPLayoutMode(kw.LayOutMode);
    MemoryFormat:= fmRichText; WP.TextLoadFormat:= 'AUTO';

    Header.DefaultMarginHeader:= ppref.HeaderMargin;
    Header.DefaultMarginFooter:= ppref.FooterMargin;

    DefaultPageSize:= wp_Letter;

    DefaultLeftMargin:= InchToTwip(http://ppref.lft/100);
    DefaultTopMargin:= InchToTwip(http://ppref.upp/100);
    DefaultRightMargin:= InchToTwip(http://ppref.rgt/100);
    DefaultBottomMargin:=InchToTwip(http://ppref.bot/100);
    DefaultPageWidth:= PixToTwip(ppref.PWIDTH, ppref.DPI);
    DefaultPageHeight:= PixToTwip(ppref.PHEIGHT, ppref.DPI);

    PrintParameter.PrintHeaderFooter:= wprOnAllPages;
    WP.Header.Landscape:= GetDocOrientation(kw.ActRep)<> poLandscape;
    ======================

    Einmal editiert, zuletzt von cps (23. Juni 2010 um 17:29)

    • Offizieller Beitrag

    The problem is the old font you are using.

    The bitmap font does not scale correctly and the FontMetric method does not provide the correct values for it. You will need a new font as replacement.

    This "bug" could have been checked quicker with more information about the application.

    BTW: The code

    Code
    var
    	L: TStrings;
    begin
    	L := TStringList.Create();
    	L.LoadFromFile('WPTest.txt');
    	// WP.MemoryFormat:= fmRichText;
    	WP.TextLoadFormat := 'AUTO';
    	WP.AsString := L.Text;
    	L.Free();
    end;

    works, but with Delphi 2010 You have an unnecessary conversion to unicode string and back to ANSI.

  • The bitmap font does not scale correctly and the FontMetric method does not provide the correct values for it.

    But it worked correctly in WPTools 4.11d. May be you have lost some functionality during version 5 development.

    You will need a new font as replacement

    It's our own font used for more than 10 years in all versions of our products and there is no source to get a "new font" from. Actually, it is a set of 5 bitmap fonts and it is simpler for us to replace an WPTools with another component than to get rid of this font.

    This "bug" could have been checked quicker with more information about the application.

    The application is planet ephemeris. The program calculates planetary positions and displays those in table form. What additional information you need?

    BTW: The code ... works, but with Delphi 2010

    Yes, it is specially built for D2010. In D7 I used WP.Text= S where S is a string of raw programmatically generated RTF text.

    You have an unnecessary conversion to unicode string and back to ANSI.

    I don't make any conversion, I guess. TString L is used as a container to load raw RTF text from file. In real application S AnsiString used as such a container.

    The problem here is solely the font. That is no TTF font - in fact it is a bitmap font and it does not scale correctly.

    Yes, it's not a TTF font but a bitmap one and there was no such problem in previous WPTools versions.
    BTW any small to medium size font we see on a screen of MS Word is actually a bitmap font. I am using a special TTF font for printing only. This is only a way to make both screen view and printed paper documents sharp and crisp.


    TTF vector fonts look on a screen acceptably only in case of very big size. Verdana TTF you see in MS Word screen actually one of MS Sans Serif bitmap fonts. Automatic rendition of TTF into bitmap screen image makes font jigged as you might see on the above screenshot.

    Anyway, thank you for your help, many things are clear now.

    P.S.
    It would be convenient if you allow forum attachments or inline images. Upgrade to phpbb3, it is much, much better and also is free.

    Einmal editiert, zuletzt von cps (23. Juni 2010 um 17:27)

    • Offizieller Beitrag

    Hi,

    I found that You can make the font working on screen with

    WP.FormatOptionsEx2 := WP.FormatOptionsEx2 + [wpfUseKerning];
    WP.FormatOptions := [wpfAlwaysFormatWithScreenRes];

    It then does not work on a virtual resolution anymore. The problem here was that
    GetTextWidth does not produce the correct values when working internally with
    600 dpi.

    The problem with font is that it does not report the correct width for the
    regular characters when symbol charset is selected. On the other hand the symbols are not printed when symbols are not selected.

    So the text must actually use the correct character set depending on the
    character itself.


    Julian

  • Spammer would use this extensively to link in illegal content

    A strict new users evaluation and pre-moderation of their first messages may be a solution.

    You can make the font working on screen with
    WP.FormatOptionsEx2 := WP.FormatOptionsEx2 + [wpfUseKerning];
    WP.FormatOptions := [wpfAlwaysFormatWithScreenRes];

    Yes, those options make document looking almost the same as WP4 original. It seems everything works as it should now.

    Your customer support is still very good, you have saved many hours of my labor. Thank you much.