Beiträge von hrc1966

    I nailed it! Created this function:

    Code
    function TPDFDoc.GetInformation: integer;const  MAXPAGES = 3000;  PAGESTRUCTSIZE = MAXPAGES shl 1 + MAXPAGES;var  i: integer;  Pages: array of integer;begin  if not assigned(wpview_pdfGetInfoW2) then    raise Exception.Create('Function pdfGetInfoW2 is not available');  SetLength(Pages, PAGESTRUCTSIZE);  result := wpview_pdfGetInfoW2(PWideChar(fOutputPath + fOutputFilename)                              , @Pages[0]                              , PAGESTRUCTSIZE                              , '' // Password                              , PWideChar(WPViewPDF_LicName)                              , PWideChar(WPViewPDF_LicKey)                              , WPViewPDF_LicCode                              , 5);  if result < 0 then    raise Exception.CreateFmt('Cannot open file: %s',[fOutputFilename]);  if result > MAXPAGES then    raise Exception.CreateFmt('Cannot fully scan file: %s',[fOutputFilename]);end;


    And when compiling the PDF, I do this (note that the fStampText.LineBreak is set to '\r\n' when created):


    This produces the result I wanted. Thanks for the sparring. Please comment if my solution can be optimized.

    Thanks for the answer.

    Quote: "simple script stored for each page" So if I want to have a "pesudo-footer" on each page in the generated file file, it can't be done? If I understand you correctly, I should add a definition for each page (or range) of the generated file. But I don't know how many pages each merged file contains. Is a possible solution to use pdfGetInfoW to get this information from each file, and build a large STAMPTEXT?

    (File numbering works somewhat OK though).

    The footer should look like this: To the left, filename of the current sub-file, to the right a page number starting from 1 to end of merged PDF-document..

    Quote: "Your code uses "for PDFDoc in self do" - do you call wpview_pdfMergeW for each file and append to the previous?". Yes and no. As I wrote, I tried both but didn't like the one where I append files to the previous. I much more liked feeding it the list of files.

    Quote: "The SaveForm message has to do with the setting of the flag UseAppearances in the PDF." So this is a setting in the PDF's forming the merged PDF? I create several formats out of COM-objects, WP and ImageEn. One must be setting this flag, right?

    Delphi 10.1, View v. 4. I'm trying to use the STAMPTEXT to add a footer to each page in a PDF I generate out of several files. The left part of the footer is intended to be the filename, the right a page number.

    Have two ideas: Merging using a string list containing all files, and one appending a file at a time. But I have great problems understanding the Options-part. BTW. what does @ClearText mean? It is mentioned several times but never explained.

    This is what I try:

    Code
    Stamps.Add('PAGENO=ALL');Stamps.Add('@clearText');Stamps.Add('NUMFORMAT=1');Stamps.Add('ORIGIN=2');Stamps.Add('-40,-25=[#]/[##]');Stamps.Add('ORIGIN=3');Stamps.Add(format('40,-25=%s',[PDFDoc.OutputFilename]));

    To start with, I built a string list containing the files to be generated, but then I can't add a footer for each new file. The above works somewhat crappy, as the [##] results in all text is printed on top of each other on page 1, one less on the next page, ending with a correct page at the last page.

    Adding the filename has the same issue.

    Code
    result := false;  ExpCount := 0;{$IFNDEF EMBEDDED}   WPViewPDFLoadDLL('wPDFViewPlus04.dll');{$ENDIF}  List := TStringList.Create;  try    List.QuoteChar := '"';    for PDFDoc in self do    begin      if PDFDoc.IsSupported then      begin        if PDFDoc.IsGenerated then          if not PDFDoc.Generate then            raise Exception.CreateFmt('PDFDoc: %s did not generate',[PDFDoc.OutputFilename]);        with PDFDoc do          if PDFDoc.Generated <> 0.0 then            List.Add(OutputPath + OutputFilename);      end;    end;    if List.Count > 0 then    begin      Stamps := TStringList.Create;      try        Stamps.LineBreak := '\r\n';        Stamps.Add(format('72,32=%s',[fFilename]));        Stamps.Add('@Page numbering part 2 - arabic');        Stamps.Add('NUMFORMAT=1');        Stamps.Add('@cleartext');        Stamps.Add('ORIGIN=2');        Stamps.Add('-40,-25=[#]/[##]');        Options := '"DEBUG=0","DELETESOURCE=1","LOGFILE='+fPath + 'pdfmerge.log","STAMPTEXT='+Stamps.Text+ '"';      finally        Stamps.Free;      end;      ExpCount := wpview_pdfMergeW(PWideChar(List.CommaText)                                  ,PWideChar(fPath + fFilename)                                  ,PWideChar('test')                                  ,PWideChar(WPViewPDF_LicName)                                  ,PWideChar(WPViewPDF_LicKey)                                  ,WPViewPDF_LicCode                                  ,PWideChar(options));      result := ExpCount > 0;    end;  finally    List.Free;  end;

    Then I tried this: Add each file individually

    This didn't work either, and It also is so clumsy that it must be the wrong approach. How do I do this the right way?

    A second issue is that when the PDF is generated, the PDF always triggers a "save form" in the Acrobat Reader. Adding a password (shown above) didn't help. Any ideas to rid this message?

    A final question to something I may have overlooked in the manuals, is how to link the DLL(s?) to the exe-file. Is there a recipe (that works)?

    Thanks in advance.
    Henrik

    Our customers have templates constructed by tables: A header-table, a vertical right for company information and one table for subject and text. The usual stuff. Sometimes the text-table span across one page. In the WPTools 6 changes to the header text works fine, but when upgrading to current version, the tables below immediately relocates to a new page instead of using up the free space on page one.

    What can I do?

    There's an example file I can ship.

    Previously used D2009 and WPTools 6, now it's Berlin and WPTools 7. Tried upgrading to newest versions of WPTools and WPdf (mine were 3 mth. old) to rule that out, resulting in a nonfunctioning IDE. I have always dreaded upgrading these two products - with good reason.

    Our system uses document templates (containing the usual letterheads and information). One (and only one) customer has a form he wants printed in A3 and creates a template, sets the pageformat to A3 and saves. When they open and use it as template for a new document, the page format is changed. The default printer supports A3, so it's not that, and I'm not able to see a pattern, and therefore, a fix for this behaviour.

    Can anyone in this forum?

    The platform is WPTools6_PREMIUM_14.10.2014 on a D2009 (If possible I'll download an update now - maybe even press for an upgrade)

    Respectfully Henrik

    (FIXED, I guess)

    When I decide to make editor readonly I run this command:

    if SetRO then
    WPRichText1.Memo.EnableProtection;

    which decrements the variable to zero, thus enabling the the ReadOnly := true assignment. ... but only when _NotingIsProtected counter reaches zero.

    D2009, WP6.29.1

    In the form constructor I set WPRichText1.ReadOnly to true but reading it immediately after the assignment, it's false.

    The Culprit seems to be this little chap:

    function TWPCustomRtfEdit.GetReadOnly: Boolean;
    begin
    Result := FReadonly and (Memo._NotingIsProtected = 0);
    end;

    where _NothingIsProtected is 1.

    Not sure if this is relevant, but the ProtectedProps is:

    [ppParProtected
    ,ppCheckAllText
    ,ppProtected
    ,ppAllowEditAtTextEnd
    ,ppProtectSelectedTextToo]

    I need this edit window to be readonly so users doesn't assume they got edit-access right until they try to save the document.

    Why is _NothingIsProtected not zero, and why is it overriding the readonly state? Shouldn't it be a component-global setting? A best approach to set the editor readonly, is greatly appreciated.

    Thanks in advance

    The XML I'm converting looks like this:

    Code
    - <Text01>  Best regards   <Break />   <bold>Dr. Suess</bold>   <Break />   15.01.2004.   <Break />   <Break />   <Break />   <Break />   <Break />   <Break />   </Text01>


    In RTF this ends up looking like this:

    Code
    Best regards
    \line <bold>Dr. Suess</bold>
    \line 15.01.2004.
    \line\line 
    \line\line 
    \line\line 
    \line\line 
    \line\line


    To many /line/line's. I would like to reduce that to just two newlines.

    The added spaces in the end of each line is something I also would like to remove. Adding (yet another) ReplaceAll with #32#13#10 replaced with #13#10 is fruitless, nothing happens.

    I get XML-data in which I need to replace <Bold> elements with the corresponding attribute for bold and such. For this I do this:

    Code
    const  BOLD_ON_Token = '<Bold>';  ...  procedure ReplaceAttribute(aRichText: TWPRichText; aStartToken, aEndToken: string; aElement: TOneWrtStyle);  var    StartID, EndID: Integer;  begin    aRichText.Finder.ToStart;    while true do    begin      if not aRichText.Finder.Next(aStartToken) then        break;      StartID := aRichText.Finder.DropMarkerAtFoundPosition(1);      if not aRichText.Finder.Next(aEndToken) then        break;      EndID := aRichText.Finder.DropMarkerAtFoundPosition(0);      if (StartID <> 0) and (EndID <> 0) then      begin        aRichText.TextCursor.SelectMarker(StartID, EndID);        try          aRichText.TextCursor.SelectedTextAttr.IncludeStyle(aElement);        finally          aRichText.TextCursor.CollectAllMarker;        end;      end;    end;  end;

    Is this a correct procedure?

    Later I remove the elements, using this (don't use wildcards);

    Code
    rtMessage.Finder.ToStart;
        rtMessage.Finder.ReplaceAll(ITALIC_ON_Token,'');
        rtMessage.Finder.ToStart;
        rtMessage.Finder.ReplaceAll(ITALIC_OFF_Token,'');
        rtMessage.Finder.ToStart;
        rtMessage.Finder.ReplaceAll(BOLD_ON_Token,'');
        rtMessage.Finder.ToStart;
        rtMessage.Finder.ReplaceAll(BOLD_OFF_Token,'');
        rtMessage.Finder.ToStart;
        ...

    When I preview the text, things look fine, but when I save to file and open in Word, the elements are still here. Wrong procedure?

    In the XML I would like to trim multiple newlines inside the text (in RTF they appear /line/lineCrLf/line/line/line.., where Cr = ascii 13 and Lf = ascii 10) and leave just one or two. Can anyone help me with a solution?

    Thanks in advance.[/code]

    I'm stuck at starting point. My task is to generate a report based on the supported datatypes of a filing system. Initially this is narrowed down to rtf and multipage tiff.

    The report is to have a header and footer, so the documents and tiff's within therefore need to be scaled down to fit the remaining space of the A4.

    The output format is to be PDF

    The WP-concept overwhelms me slightly, but I expect something like this:

      1. Generate/load a report template with a header and footer
      2. For each supported document/data
      2a. If not tiff, convert to tiff
      2b. Scale to 80% and add image to report template, one image per page.
      3. When done, insert a TOC at first page.
      4. Convert to PDF (using TWPDFExport I guess)


    Currently we're using Delphi 2009, with WPTools 6 premium and wPDF 3 Plus.

    Can anyone please help me get started? Which components am I supposed to start with? Is there an easy way to access the image of a page, in order to downscale it? Should we upgrade WPTools? Demos?

    I have to figure out a way to allow toggling the protective flag. I'm close to a beginner in this document concept and almost lost in it.

    Using D2009, with the latest brew of WPTools 6 (12.12.2012) I have modified the WPT2009Project1 so it contains a TWPRichText from start.

    Code
    wprtEditor.ProtectedTextAttr.BackgroundColor := clYellow;wprtEditor.ProtectedTextAttr.UseBackgroundColor := true;wprtEditor.ProtectedTextAttr.UseTextColor := false;wprtEditor.ProtectedProp := [ppParProtected, ppCheckAllText, ppProtected, ppAllowEditAtTextEnd, ppProtectSelectedTextToo];


    Maybe I've added too many procetion properties? Maybe not relevant, this it the EditOptions:

    Code
    wprtEditor.EditOptions = [wpTableResizing, wpTableColumnResizing, wpObjectMoving, wpObjectResizingWidth, wpObjectResizingHeight, wpObjectResizingKeepRatio, wpObjectSelecting, wpObjectDeletion, wpSpreadsheetCursorMovement, wpActivateUndo, wpActivateUndoHotkey, wpActivateRedo, wpActivateRedoHotkey, wpMoveCPOnPageUpDown, wpAllowCreateTableInTable];


    I try to use this snippet to toggle but all it does is setting the attribute. Undoing has never worked.

    Code
    if afsProtected in wprtEditor.CurrAttr.Style then
      wprtEditor.CurrAttr.DeleteStyle([afsProtected])
    else
      wprtEditor.CurrAttr.AddStyle([afsProtected]);


    What is the right procedure, please?

    When in text surrounded by the \wpprot, I assume the DeleteStyle seeks in both ways for the attribute to remove. Are there navigational functions to seek start and end of a given attribute.

    Hi Julian. I just upgraded my version and the glyphs in the preview form are missing. The source files I can find are dated 27-10-2009 so it seems that the mentioned updated dfm-file has passed me by. .. or perhaps the files found are not used in building the component

    Can I download it separatly, do you have an alternative fix or will it be in the next update?

    .. A follow up. I tried the WP5 solution and it worked. My problem's solved and I assume that following updates contain the proper images.

    Hi Julian. Hope you see this even after so long. The problem is still here but has never been a big issue to our customers. They would like to see it fixed though.

    It is not just Notes but also a browser specific problem. Copying data from the IE9 is garbled whereas Chrome data is fine.

    I have dumped the clipboard contents to files as you suggested, one directly from the IE9, one doing a "touch and go" at MS-Word and one from from Chrome. The last two works fine. It seems that the IE9 copy pastes rtf-code with no line breaks. Chrome and Word inserts <CrLf> for every 300 chars and so.

    Is there a way I can issue a break-command before inserting into the document?

    I insert a signature file through mail merge:


    Code
    procedure TfrmWordProcessor.WPRichText1MailMergeGetText(Sender: TObject;                                                        const inspname: string;                                                        Contents: TWPMMInsertTextContents);var  Index: integer;  FilePath: string;  SignatureWidth: integer;  SignatureHeight: integer;begin  Index := StrToIntDef(inspname,-1);  if Index = fDMWordProcessor.BRUGER_SIGNATUR then  begin    FilePath := ParseEnvironmentStrings(GetSystValue(scPaths,'SignaturePath','.\'));    if FileExists(FilePath) then    begin      SignatureWidth := GetSystValue(ScSystem,'SignaturWidth',0); // in twips, 0 = "as is".      SignatureHeight := GetSystValue(ScSystem,'SignaturHeight',0);      Contents.LoadImageFromFile(FilePath,SignatureWidth,SignatureHeight);    end;  end  else    Contents.WideStringValue := fDMWordProcessor.GetString(StrToIntDef(inspname,-1));end;

    This piece of code inserts the signature without actually using the SignatureHeight, thus maintaining the proportions of the image.

    I also insert the image through an action:

    Code
    procedure TfrmWordProcessor.aUserSignatureExecute(Sender: TObject);var  FilePath: string;  SignatureWidth: integer;  SignatureHeight: integer;  image: TWPOImage;begin  FilePath := ParseEnvironmentStrings(GetSystValue(scPaths,'SignaturePath','.\'));  if FileExists(FilePath) then  begin    SignatureWidth := GetSystValue(ScSystem,'SignaturWidth',0); // in twips, 0 = "as is".    SignatureHeight := GetSystValue(ScSystem,'SignaturHeight',0);    image := TWPOImage.Create(WPRichText1);    Image.LoadFromFile(FilePath);//    Image.WidthTW := SignatureWidth;//    Image.HeightTW := SignatureHeight;    WPRichText1.TextObjects.Insert(Image,SignatureWidth,SignatureHeight,DM.UserData.Name);  end;end;

    This method apparently make use of the SignatureHeight and the results differ. How do I make the two methods produce the same result?

    Followup. I ended up using this. But is there a better solution?


    Code
    SignatureWidth := GetSystValue(ScSystem,'SignaturWidth',0); // in twips, 0 = "as is".
    
    
        // To make dimension adjustments proportional
        if Image.ContentsWidth = image.ContentsHeight then
          SignatureHeight := SignatureWidth
        else 
          SignatureHeight := muldiv(SignatureWidth,image.ContentsHeight,Image.ContentsWidth);

    When our customer paste mails from Notes directly into our app. the text is reduced to dots and what have you. If he pastes into Word and then into our program, it works.

    It seems that TWPRichText doesn't have a fall back font, or what?

    I have found this code snippet and wonder if this is something to try: http://wpcubed.com/forum/viewtopi…;highlight=font ... but where should it be run? The BeforePasteText-event? Is this the best solution or can I choose a fall back font somewhere?

    Something like this?

    If I instead use the AfterLoadText I expect things already are garbled.

    Our editor-form use the standard TWToolbars but because the form is MDI we cannot use TMainMenu which attaches to the main form. Instead we use TActionMainMenuBar (and TActionManager) as it stays in the edit-form.

    The problem is that the toolbar buttons and the menu actions aren't connected. They work in parallel and I don't like that. If I select the "Protected Text"-button the menu action must to be checked etc.

    The obvious solution is to ditch the TWPToolbars and make'm ourselves, but that a big task. Other suggestions are most welcome.

    One of our customers complain that it is difficult to use the mouse to select text spanning more than one page (they probably also complain about read lights). The scroll speed is quite difficult to control, I agree that it scrolls quite fast, but I have never considered this a problem, nor an issue because I use shift and arrows to select.

    Any idea on how to slow down the scrolling?

    Thanks in advance.

    In the bottom of the method adding the headers, footers and first page info, I found these two lines.

    Code
    aWPRichText.SelStart := aWPRichText.GetTextLen;
    aWPRichText.InputString(#13#10#13#10#13#10);

    Apparently they had the SelStart placed in the middle of the title-line. The lines were deleted and the report worked.

    Can anyone tell me the correct way to move the current position to the bottom or why the above failed?