Beiträge von JayM

    I have a license for WPTools for > 10 years but not for WPViewPDF (yet). I use Delphi 2007 and XE2. WPTools has been great!

    Question: This is what I would like to do programmatically
    1. Open a standard PDF document (PDF created by others. I will have no control on this).
    2. Copy each paragraph in the PDF document to TStringList items as Plain Text.
    3. Do whatever with the text in TStringList items.

    So, if XYZ.pdf has 10 paragraphs, I will have 10 items in the StringList. Each item will have plain text (i.e., all formatting removed) of the respective paragraph.

    I would think this would be trivial for WPViewPDF but want to make sure that it is easily accomplished BEFORE ordering the VCL component.

    Can WPViewPDF do what I am asking above?

    Thanks

    JayM

    Julian,
    Thank you for your reply. However, using "AsANSIString('WPT')" instead of "AsString" does NOT solve the issue. I am still losing hyuperlink color when I try code like following.

    I may be missing some property assignments, etc., but don't know what!

    Thank you for your help.

    JayM

    Delphi 2007, WPTools [V5.51], Windows Vista

    This question is [sort of] continuation of: http://wpcubed.com/forum/viewtopic.php?t=6130

    Context: In my app, user can select an item from a Popup Menu when he/she clicks on a Hyperlink in WPEditor. The Hyperlink's color is set based on user selection (see Julian's excellent response re: Hyperlink --> Popup Menu:
    http://wpcubed.com/forum/viewtopi…hyperlink+popup)

    Problem: WPEditor can have hyperlinks in different colors based on user selection (e.g., Unmodified = clBlue, UserModified = clNavy, if Embedded text is "Delete Para" then clRed, etc). Problems is that Hyperlink colors are lost after original text is saved and restored (see code below).

    User can "Preview" the output as "PlainText" and on closing Preview, returns to WPEditor. I save WPEditors contents with "AsString", modify contents for preview and finally restore the original contents as shown in the abbreviated code below.

    In form initialization code:

    Code
    With WPEditor.HyperlinkTextAttr do begin    TextColor := clBlue ; {Default color }    {Following must be false so that we can change font color     and underline color in code}    UseTextColor        := false ;    UseUnderlineColor := false ;end;

    "Preview" button.OnClick() -- Abbreviated

    Code
    With WPEditor do begin        { Keep a Copy of WPEditor's Text and CPPos, etc because we are            about to change it. Reset back to normal when exiting            the preview mode }        wpPreview_EditorTextAsString := WPEditor.AsString ;        wpPreview_CPPos := CPPosition ;        wpPreviewTopLineIndex := TopOffset ;       ... {modify WPEditor's contents for preview}       { Display modified text in TMemo as pain text}       aMemo.Text := WPEditor.Text ;end ;

    "Close Preview" button.OnClick() -- Abbreviated

    Interestingly, all text including Hyperlink text and Hyperlink underline color is changed to clBlack (note that default color for Hyperlink is set to clBlue).

    How can we preserve the original Hyperlink color after executing code like above? Any work-arounds?

    Thank You

    JayM

    Though I can get list of Hyperlink objects and loop through them, I still can't figure out how to conditionally change Font color of each hyperlink, i.e., some hyperlinks need to be shown with Font Color clBlue while others may be shown with font color clRed.

    TWPTextObj.Style and TWPTextObj.StyleName properties are read-only - so, I can't assign font attributes using TextStyle to these properties.

    May be I am approaching this in a totally wrong way and there is a simpler answer that is escaping me because I don't use WP Tools all the time.

    Please help. Thank You.

    JayM

    Delphi 2007, WPTools [V5.51], Windows Vista

    The one page document has plain text (nothing fancy) and Hyperlink objects that were created using: WPEditor.InputHyperlink() at runtime. There are no other text objects in the document that I am aware of. Document starts as plain text (e.g., text copied from Notepad - so, there is no HTML or RTF markup when text is loaded into WPEditor).

    Code
    procedure TForm1.TestClick(Sender: TObject);var    aTextObjList : TWPTextObjList ;    i, nObjCount : Integer ;begin   WPEditor.FieldGetList(aTextObjList, True, '') ; // [b]<-- Access Violation[/b]   // Other code intended to loop through objects - Never reached.end ;

    Eurekalog points the error to this line:
    List._StringParam := NameStartWith;

    Code
    procedure TWPCustomRtfEdit.FieldGetList(
      list: TWPTextObjList; FromAllBlock: Boolean = FALSE;
      NameStartWith: string = '');
    begin
      List.Clear;
      List._StringParam := NameStartWith;  
      if FromAllBlock then Memo.RTFData.LoopAllObj(List, LoopFieldsB, nil)
      else Memo.RTFData.LoopAllObj(List, LoopFieldsB, Memo.DisplayedText);
    end;

    What am I doing wrong? Even if there are zero objects, I should get a blank list, and not an Access Violation.

    I need to get list of ALL Hyperlink objects and be able to loop through to conditionally change Source text and changes Source text's color. Any help to accomplish that will be appreciated.

    Thank you

    JayM (occasional WPTools user)

    Adding comments to my post: One would assume there is ONLY ONE header.DefaultTabStop setting that applies to the entire document. Not so.
    For example, I have a document with DefaultTabStop set to 720. I copy/merge a few paragraphs from another document that has DefaultTabStop set to 1440. In this case, the old and the newly added paragraphs keep their original TabStop/Indent value.

    Further, selecting all text and chaning DefaultTabStop value does NOT change the entire document to the new setting. Each paragraph STILL keeps its old DefaultTabStop setting as noted above.

    I wonder if there is a paragraph level property that is controlling/affecting this behavior.

    Thanks

    JayM

    Delphi 2007. WPTools v.5.51, Windows Vista

    To change Indent (next level/prior level) and TabStop, I have this simple wrapper function that I call from user interface (menu item).

    Code
    Procedure WPT_Set_TabStop(RTFMemo : TWPCustomRtfEdit; nTwips: Integer);
    begin
        RTFMemo.Header.DefaultTabStop := nTwips;  {Tab Stop}
    end ;

    Problem:
    Setting a different value for Header.DefaultTabStop (e.g., from 360 to 720 twips) does NOT seem to work consistently (at times it seems to work as expected, at other times, TabStop value does not change at all).

    Is there another property that may be interfering or do I need to call some code to make this property take effect?

    Note: When application starts, I am initializing page margins and default tab stop. This, of course, does not help the existing documents that already have the header info saved in file. So, I am trying to over-ride old header info in code as noted above.

    I DO have to work with EXISTING documents (no choice) that need page margin and indents adjusted. So, I am trying to apply page margins (works fine) and default tab stop (not working fine :( ) to existing documents via menu items AFTER loading the document.

    (To actually increase or decrease paragraph indent level, use code copied from: WPCtrRich...WPI_CO_NextLevel and WPI_CO_PriorLevel...from button.OnClick(). This works as expected.)

    Thank You

    JayM

    Delphi 2007, Win 32 app, running on Windows XP.
    WPTools version 5.51

    In my application, users create documents (letter) in WPRichText and eventually paste them in their business app for storage. They copy text in WP Editor using a popup menu which has this one line of code: WPRichText_Ltr.CopyToClipBoard(true);

    There are no tables or graphics or other fancy stuff in the documents - just text. Documents are not saved to file by my App - simply copied from it. Templates, which serve as starting point for letters have been saved in WPT format.

    Most of the time copy and paste function works fine. However, I have been getting reports that, at times, on using above menu option, NOTHING GETS COPIED to clipboard. Using right click on target app, e.g., Notepad, "Paste" option remains grayed out meaning there is nothing on clipboard).

    Today a user demonstrated this to me: I could verify that indeed it was problem in software and not "operator error" or false alarm. Nothing got copied to Clipboard even with text highlighted (the above command does not need text highlighted). I have a button in App that closes and FREEs the form thus WPRichText and other controls are recreated when form opens next time. Even doing that did not solve the above problem.

    Any ideas ? (I understand that this is very sporadic and will be virtually impossible to reproduce. Has anyone seen this behavior elsewhere - with/without WPRichText? Could this be something to do with Windows rather than WPRichText ?) Any insights are appreciated.

    Thanks

    JayM

    Delphi 5, WP 5.48

    For Toolbar SelNextLevel / SelPriorLevel buttons: How do I get / set value for how much indent will occur on button click?

    For example, I want SelNextLevel to indent paragraph by 360 twips. However, I don't know how to find out what the current setting is and how to change it. I looked at toolbar properties but did not see anything that will allow setting this value.

    How do I do that?

    Thanks

    JayM

    WPTools 5.48.5, Delphi 5, Windows XP Pro

    Julian:

    This is a follow up on my original post: "Bookmarks tags getting DELETED AND REPLACED with [ch=1] tags" on Aug 02, 2009.

    First, the issue I reported in the above post DID NOT occur once I changed bookmark names to one word (i.e., no spaces in names). Not sure if this is just a coincidence or a real problem resolution!

    However, I took your advice and changed the code to use Edit Fields instead of Bookmarks to maintain document structure per discussion in my previous post.

    Now, I have run into following which occur only when: ProtectedProp.ppAllExceptForEditFields := true

    Following should be easy to reproduce with minor modifications to: TextObjects demo project (I just added a button to input Hyperlink and a checkbox to toggle ProtectedProp.ppAllExceptForEditFields property).

    1. Hyperlinks in EditField Text: On moving backwards in text with Left Arrow key, when cursor reaches end of a Hyperlink, next Left Arrow keypress exits the current EditField and puts cursor in the EditField before the current one.

    2. Going forwards with Right Arrow key: As soon as keyboard cursor enters EditField, it goes to last character in the EditField. In my case, EditField may contain any amount of text, typically 1-6 lines. I can imagine this could be intentional/helpful in certain conditions (forms with short data entry fields) but it will totally confuse and irritate other users.

    3. [Not too important to me right now but may be to others] Home and Control-Home keys take cursor to end of the previous EditField though Control-End take cursor to end of the document. Again, this may be intentional and beneficial in certain circumstances except the Control-Home key behavior which should take cursor to either top of the document or to the first EditField in the document/form.

    All these are issue with keyboard navigation only, not with mouse. However, for Section 508 compliance in USA, we have to ensure that users can accomplish the same tasks without mouse.

    Further, since the whole idea of using Edit Fields is to maintain document structure and control where user input goes, I must limit user data entry to provided EditFields. Therefore, ability to set: ppAllExceptForEditFields := True is very important.

    Are there any properties/settings that I am missing? As always, all help is greatly appreciated.

    With best regards,

    JayM

    Code
    I would expect that users who type into the structure accidentally select over the end of a bookmark and delete so part of the markers.

    I should have mentioned this: All the Bookmarks are protected and tags can not be accidently deleted by user editing.

    Code
    ...use mailmerge fields or better edit fields...

    While I personally agree with you, the issue is current workflow and "industry standards" - i.e., users are used to doing things a certain way for years and any change is resisted even if it is for better.

    Right now, users work with a blank editor and create/type text where-ever, as much/as little and in any order. As you may suspect, they are resistant to "filling out fields in a form..." type of application since historically, medical progress notes have always been totally free-form.

    BTW: I don't have the Pro edition yet but can get one if that will be of help. In which case, I really need to look at version 6.

    As always, I appreciate your support and suggestions.

    JayM

    First, thanks for the prompt reply even when you are on vacation.

    Code
    You can display the bookmark codes using a setting in the FormatOptions.

    I am already doing this - there is a menu option to show/hide bookmarks. However, this works only for the developer. My users will not have a clue what they are looking at, and could not care less about "how and why."

    Code
    I see your demo file and - it is very complicated.

    No really - just a bunch of bookmarks in Heading and BodyText pairs. Let's not forget: You are way smarter than I am...,<seriously>

    Code
    ...insert the text using StartTag.EmbeddedText, don't use SelectionAsString, it makes things unpredictable.

    Any guidance on: How can I do that without losing existing text within the bookmark?

    The current method (Bookmarks + InputString or SelectionAsString), support the requirement that user may need to insert multiple templates PLUS hand-type text in the same bookmark. For example, exam of left Eye may be ABnormal, and right Eye Normal. In this case, user will use two separate templates, a detailed one and a short one PLUS type in a line or two if template does not describe findings adequately. Therefore, we can't replace everything within a bookmark with StartTag.EmbeddedText. SelectionAsString allows me/user to put the cursor in the proper place and add to existing text.

    Code
    I might make it possible to use mail merge with bookmark objects in V6.

    Thanks - I will explore this when available. My initial impression is: This may NOT help my current model where user needs to "mail-merge" multiple templates PLUS free text into the same field (a bookmark).

    A progress note does NOT require that all fields (bookmark placeholders) be filled - their purpose is to provide a consistent structure. Typically, users input data into 12-15 items as relevant to the given patient. On screen, WP Editor only displays user entered text (remaining headings/bodyText are not visible until they contain some text).

    "Displaying" all items as mail-merge fields will intimidating and will imply that users need to fill all 120 fields which is not required.

    BTW: I have changed all bookmark names to be one word (there were spaces in names in the files I sent you). This may not have anything to do with the problem at hand but worth a try.

    Again, thank you very much and I am looking forward to learning what you find and fix.

    JayM

    WP Tools: 5.48.5, Delphi 5, Windows XP. Two WPT files sent by e-mail to support_at_wptools.de. (My apology for a long post but there is no easy way to describe this problem clearly.)

    I am developing an application that represents about 60 items in a WP document to define structure of a medical progress note.

    Each item in the progress note is represented by a Heading bookmark and a BodyText bookmark (e.g., "Examination of Heart" will have a heading and details (body text) of physician's findings). Thus, there are ~ 120 bookmarks in the document.

    All bookmarks are created into a blank editor when user starts a new note (editor has already been initialized with: RTFMemo.CheckHasBody; par := RTFMemo.FirstPar;). These are placed in pairs in the editor in a For...Loop using BookmarkInput() (Heading_XYZ then BodyText_XYZ) so they are always in that order and in a pair.

    Bookmarks are NOT added, deleted or moved once they are placed in the WP editor. Until filled by user action, bookmarks remain blank (i.e., contain no text between start and end tags.)

    Application provides interface to add predefined text fragments into bookmarks (either plain text or WP formatted text). Text is placed inside the bookmark by setting CPPosition inside the bookmark and using either InputString() (if it is plain text) or using SelectionAsString (if it is WPT formatted text).

    Of course, user can also directly type into the WP Editor. Idea is simple: bookmarks provide a structure and user action adds text.

    Basically, this works well except when it doesn't <g> as noted in this post.

    Problem described below occurs FREQUENTLY AND UNEXPECTEDLY. So far, I have not been able to identify a sequence of steps that will consistently reproduce the problem .

    I am sending TWO files as e-mail attachment - one where process [mostly] worked as expected and 2nd when similar steps deleted/changed bookmarks tags to invalid tags (e.g. opening tag [ch=2] is changed to [ch=1] ). Please see snippets from these files below.

    Problem: Inserting text into a bookmark sometimes:
    1. Deletes opening bookmark tags and changes order of bookmarks. These tags seem to be replaced by [ch=1].
    2. Order of bookmarks is changed.
    One look at file: "Bookmarks_When_Error.WPT" will show you the nature of this error.

    The 2nd file, "Bookmarks_When_Good.WPT" shows output and bookmarks when process works correctly. It was created with SIMILAR STEPS. I included this to show how Bookmarks look when this problem does not appear in display (Even this file shows some [ch=1] instead of [ch=2]).

    This may help you debug: Normally, HD-xyz (heading bookmark) always comes before BT-xyz (BodyText bookmark) as follows (from "Good" file). Note that order of first two pairs is correct but then bookmark order is reversed (BT-xyz has moved before HD-xyz):

    Code
    <begin Tag=259 style="Name:'HD-Chest';" wpsty=[[Type:3;Mode:3;Name:"HD-Chest";]] ch=2/><end Tag=259 ch=3/><begin Tag=260 style="Name:'BT-Chest';" wpsty=[[Type:3;Mode:3;Name:"BT-Chest";]] ch=2/><end Tag=260 ch=3/><begin Tag=261 style="Name:'HD-Breast';" wpsty=[[Type:3;Mode:3;Name:"HD-Breast";]] ch=2/><end Tag=261 ch=3/><begin Tag=262 style="Name:'BT-Breast';" wpsty=[[Type:3;Mode:3;Name:"BT-Breast";]] ch=2/><end Tag=262 ch=3/><begin Tag=263 style="Name:'BT-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Followup Visit";]] ch=1/><begin Tag=264 style="Name:'HD-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Followup Visit";]] ch=1/><begin Tag=265 style="Name:'BT-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Imaging Orders for Next Visit";]] ch=1/><begin Tag=266 style="Name:'HD-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Imaging Orders for Next Visit";]] ch=1/><begin Tag=267 style="Name:'BT-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Lab Orders for Next Visit";]] ch=1/><begin Tag=268 style="Name:'HD-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Lab Orders for Next Visit";]] ch=1/>

    But, in "Error" file (Below), and a few in "Good" file (above):

      1. "Order" of bookmarks has changed. Now, for many items, BodyText (BT-xyz) shows up BEFORE heading bookmark (HD-xyz).
      2. Opening Tag (ch=2) and Closing Tag (ch=3) have been replaced with ch=1 for many bookmarks.
      3. There are some (ch=1) tags in "Good" file too. These may represent an error but since I did not fill these bookmarks with text, I did not notice them in interactive mode (only noticed these while examing WPT file).

    Needless to say, this is a Show-Stopper. I have full faith you will take care of this ASAP.

    Thanks in advance.

    JayM

    WP Tools: 5.48.5, Delphi 5, Windows XP.

    Problem: Assume some text already exists in the WP Editor. Using a Combobox (or Macro expansion), user insert 10-20 lines of text near top (or bottom) of the editor. Depending on number of lines added, the new text may easily fit in the visible window OR part of it end up below bottom (thus TopOffSet should be adjusted) OR there are too many lines to fit (thus the question in this post.)

    Key Point: User needs to review/edit newly added text. Therefore, to the extent possible, new text needs to "stay" in the visible area of Editor.

    The obvious solution will be to know TopOffSet and current line number before text is added and calculate how many lines have been added so that TopOffset can be recalculated. I can figure that much. But to really position newly added text accurately, I also need to know: HOW MANY lines are visible in the editor.

    Note: There are NO tables or graphics in the document - just rich text.

    Question: How do I find out HOW MANY lines of text are visible in the editor?

    For example, I can visually count that in my current implementation, 30 lines of text are visible in editor. Needless to say, number of visible lines will change if editor window is resized or Font / Zoom are changed.

    As Always, thanks in advance.

    JayM

    WP Tools v 5.48.5, Delphi 5, Windows XP

    In a test project, using a Checkbox, I can set the Footer Shading (BG Color) as expected. However, when I want to UN-DO the shading, I "should" be able to set the footer shading color to Editor.PaperColor so that shading will not be visible. However this part does not work.

    So, if Editor.PaperColor is set to clInfoBK, footer shading remains gray. This works fine if I keep PaperColor to clWindow and call "WPT_Set_Footer_Shading()" below.


    In essense, Footer Shading "UNDO" works ONLY IF Editor.PaperColor = clWindow but NOT if PaperColor is anything else.

    Am I missing something here? Is there a better way to approach this?

    Thanks

    JayM

    Delphi 5, Windows XP, WPTools v5.39 (yes, I know...May be this weekend)

    Assume a document with 8 paragraphs. User clicks in middle of third para and drags mouse to middle of 5th para. So, some text is selected in 3rd para, all in 4th para and some in 5th para.

    Question 1. How do I identify in code which paragraphs contain selected text? Using above example, code should identify para number 3, 4 and 5 as ones with selected text.

    Question 2. How do I change font properties of the ENTIRE para, not just the selected text? Using Example above, I want to toggle Strike-out font for ENTIRE text of Para 3, 4 and 5.

    The pseudo-code below shows what I need!

    As always, your help is greatly appreciated.

    JayM

    Delphi 5, WP Tools 5.39 (yes, 5.44 is better - I will update), Windows XP.

    Hello,

    My application uses WP Tools for simple stuff - display and user editing of text. So, I don't use WP Tools features extensively. The side-effect: I get stuck on simple stuff. Here is another one of those. On the good side, I don't bother Julian except, may be, once a year.

    Issue: Our users select a template as starting point for their document. They can freely edit this document (type, paste, dictate into). I need to add "Advisory" paragraphs in templates. Users can not delete/edit "Advisory" paragraphs (protected text). Before saving text, applications deletes "Advisory" paragaphs.

    This is what I need:
    1. When creating templates: Code for button click event which makes the active paragraph "protected" and sets a different color/font for whole para.

    2. When saving edited document (this still has protected "Advisory" paras in it) - identify and remove protected paras.

    I have searched forums and found quite a few posts but none offering a clear solution to what I am looking for (compounded by my limited understand of internals of WP Tools).

    Please provided guidance including sample code how best to approach the above issue.

    Thank You very much


    JayM

    PS: WP Tools is a great product and great support too. It has been very stable in our application - can't ask for more. THANKS.