This happens when I create a new dossiers.
The content in the database is of course empty at that point of time.
Is there a way to solve this?
This happens when I create a new dossiers.
The content in the database is of course empty at that point of time.
Is there a way to solve this?
Hi Julian,
In WPTools 5 this only changed the background of the paper into red (in wplayLayout). Even when the control didn't have the focus.
In WPTools 6 the color of the background and the paper are both changed into red (in wplayLayout) when it doesn't have the focus. When it has focus only the background is red.
Is this changed for some reason of is it a bug?
Regards,
Stef
Hi Julian,
I figured out what went wrong here.
Appearently the OnChange-event isn't fired when the TWPRichText is loaded by code like the above.
Therefor my check for IsEmpty was never executed. This is now solved.
Thanks for your help.
Stef
Hi,
My application uses a TWPRichText (no TWPDBRichText).
I store the content of a RichText into a database.
I load the content from the database into the WPRichText, like:
After that I'll check if the text is loaded:
This always returns True (even though the content is correctly loaded into the editor).
Can you direct me in the right way, on how to update the editor somehow so it recognizes the content?
Thanks, Stef
I needed the file too.
Found it on:
http://www.addictivesoftware.com/3rdparty.htm
You need to download:
WPTools6 : "Parser only"
The function CodeMoveTo works indeed perfectly.
Thanks for the tip Julian.
Hi Julian,
I seem not to have a TextObject.Name called 'SECTIONPAGES'.
I only have 'PAGE' and 'NUMPAGES'.
Changing the code into one of the other doesn't give the expected result.
Can you tell me how to get this working?
Regards, Stef
Thank you very much.
Adding the wpsec_ResetPageNumber to the select didn't do it:
Pagenumbers are still numbers as:
Document for customer A: Page 1 of 4, Page 2 of 4
Document for customer B: Page 3 of 4, Page 4 of 4
Do you have any idea why it is not working?
Regards,
Stef
Hi,
For the first part of your question the following code might be useful for you. It's not exactly what you want but very close I believe:
function TFMailings.ZoekMergeVeld(MergeveldNaam : String) : Integer;
var MergeVeld : TWPTextObj;
begin
// Find startingposition of a specific mergefield
Result := 0;
if True then
begin
with MailingEditor.Finder do
begin
ToStart;
while true do
begin
if not Next(MergeveldNaam) then
break;
// position the cursor at the foundposition
MailingEditor.CPPosition := FoundPosition;
// Check if it is the correct mergefield.
MergeVeld := MailingEditor.FieldAtCP;
If (MergeVeld <> Nil) then
begin
if (MergeVeld.Name = MergeveldNaam) then
begin
// Your mergefield is found at the cursor position
MailingEditor.TextCursor.MoveTo(MergeVeld.StartTag);
MailingEditor.CPMoveBack; // Place the cursor in front of the mergefield
Result := MailingEditor.CPPosition;
Break;
end;
end;
end;
end;
end;
end;
Alles anzeigen
Question 3 and 4 are solved. I use following code to accomplish it:
begin
// Add horizontal line at the top of the footer
par:=MailingEditor.HeaderFooter.Get(wpFooter,wpraOnAllPages).FirstPar;
par.ASet(WPAT_BorderFlags, WPBRD_DRAW_Top); // Top
par.ASet(WPAT_BorderWidth, WPCentimeterToTwips(0.02)); // 0,5 mm
par.ASetColor(WPAT_BorderColorT, clBlack); // Black line
end;
Please have a look at question 1 and 2.
Regards,
Stef
Hi,
When I add pagenumbers into a mailmerge document, like:
par.Insert(0, 'Page: '), txtplain); par.InsertNewObject(maxint, wpobjTextObject, false, false, txtplain).Name := WPTextFieldNames[wpoPageNumber]; par.Insert(maxint, ' of ', txtplain); par.InsertNewObject(maxint, wpobjTextObject, false, false, txtplain).Name := WPTextFieldNames[wpoNumPages];
Then the pages are counted and numbered for all the generated pages (regardless of the customer). The mergedocument is merged into one new document.
Is there a way to number the pages for each customer. Like:
Document for customer A: Page 1 of 2, Page 2 of 2
Document for customer B: Page 1 of 2, Page 2 of 2
Maybe there is a way to transform "wpoPageNumber" and "wpoNumPages" into the actual numbers the moment the document is merged. See basically your code from Mail4-project below:
Thanks, Stef
procedure TFMailings.btMaakDocumentenClick(Sender: TObject);
var i : Integer;
Section : TWPRTFSectionProps;
begin
If cbToonVeldcodes.Checked then
cbToonVeldcodes.Checked := False;
QAdressenSelectie.DisableControls;
try
wptAlleBrieven.BeginUpdate;
QAdressenSelectie.First;
i := 0;
while not QAdressenSelectie.EOF do
begin
Inc(i);
QAdressenSelectie.Next;
end;
pbVoortgang.Properties.Max := i;
QAdressenSelectie.First;
i := 0;
wptAlleBrieven.Clear;
while not QAdressenSelectie.EOF do
begin
pbVoortgang.Position := i;
MailingEditor.MergeText;
if i = 0 then // FIRST RUN
begin
wptAlleBrieven.AsString := MailingEditor.AsString;
wptAlleBrieven.CPPosition := MaxInt; // to end
end else
if i > 0 then // SUBSEQUENT RUNS
begin
// Append a new paragragraph IF the last line is not empty
if wptAlleBrieven.ActivePosInPar>0 then
wptAlleBrieven.InputString(#13);
// Need page break
wptAlleBrieven.FastSetPageBreak(true, true);
// and append the text
Section := wptAlleBrieven.FastAppendText(MailingEditor,true);
Section.Select := [wpsec_PageSize,wpsec_Margins,wpsec_ResetOutlineNums];
end;
Application.ProcessMessages;
QAdressenSelectie.Next;
inc(i);
end;
sbMergedocumenten.Panels.Items[1].Text := IntToStr(QAdressenSelectie.RecordCount);
finally
wptAlleBrieven.EndUpdate;
QAdressenSelectie.EnableControls;
end;
end;
Alles anzeigen
Hi,
When I add an image into the header I mark it with a bookmark.
Before I add the image a second time I need to know if it was already added and therefor I check if the bookmark is still there (if not: it will be created).
Here is my problem.
It seems the bookmark can't be found in the Header. It is recreated each and every time. How can I check if the image is added to the header and if it's still there (bookmark isn't empty)?
* The same situation applies for added bookmarks (with text in it) in the footer, so please keep that in mind when answering this question.
With kind regards,
Stef
if (DM.TEigenBedrijf.FieldByName('Logo').IsBlob) and (not(DM.TEigenBedrijf.FieldByName('Logo').IsNull)) then begin try // Prepare Streams TempImageFile := ExtractFilePath(Application.ExeName)+'TempImage.jpg'; DM.TEigenBedrijfLogo.SaveToFile(TempImageFile); MyBlobStream := TMemoryStream.Create; MyBlobStream.LoadFromFile(TempImageFile); // as demo wpImgObj.LoadFromStream(MyBlobStream); wpImgObj.WidthTW := wpImgObj.ContentsWidth; wpImgObj.HeightTW := wpImgObj.ContentsHeight; MailingEditor.HeaderFooter.Get(wpIsHeader, wpraOnAllPages, '').WorkOnText := true; If BookmarkAanmaken('KoptekstLogo') then begin with MailingEditor.TextObjects.Insert(wpImgObj) do begin PositionMode := wpotPar; RelX := (MailingEditor.Header.PageWidth - 2600); end; MailingEditor.CPMoveNext; // Plaats de cursor buiten de bookmark end; finally MyBlobStream.Free; if FileExists(TempImageFile) then DeleteFile(TempImageFile); end; end;
function TFMailings.BookmarkAanmaken(BookmarkNaam : String) : Boolean;
begin
HuidigeCursorPositie := MailingEditor.CPPosition; // Opslaan huidige cursorpositie
if (MailingEditor.BookmarkFind(BookmarkNaam) >= 0) then
begin
if MailingEditor.BookmarkSelect(BookmarkNaam,true) then // Bookmark selecteren
begin
if MailingEditor.SelLength > 0 then // Controleren of er tekst in de bookmark staat (0 = leeg)
Result := False
else
begin
MailingEditor.BookmarkDelete(BookmarkNaam,true,true); // Oude bookmark verwijderen
MailingEditor.CPPosition := HuidigeCursorPositie; // Verplaats cursor naar opgeslagen positie
MailingEditor.BookmarkInput(BookmarkNaam,true); // Bookmark invoegen
Result := True;
end;
end;
end else
begin
MailingEditor.CPPosition := HuidigeCursorPositie; // Verplaats cursor naar opgeslagen positie
MailingEditor.BookmarkInput(BookmarkNaam,true); // Bookmark invoegen
Result := True;
end;
end;
Alles anzeigen
Thank you very much this helped me in the right direction.
Hi,
Question 1:
I would like to add a line to the WPRichText in the current place in the document (body, header, footer).
This line must exactly fit between the margins that are set by the horizontal ruler of the WPRichText.
Question 2:
I would like to be able to select an inserted line and change the width, height and position in the document. Can this be done?
Question 3:
How to get a line at the top of the footer so it remains there even is text is added to the footer?
Question 4:
How to get a line at the bottom of the header so it remains there even is text is added to the header?
For adding a line I use following code, maybe this isn't the right code in every situation.
with MailingEditor.TextObjects.InsertNewObject(wpobjHorizontalLine, false, false) do
begin
width := WPCentimeterToTwips(MailingEditor.Width);
Height := 1;
iParam := clBlack;
end;
MailingEditor.Refresh;
Thanks,
Stef
Yes, thank you very much, this is working perfect.
The example is loading the image from a file, but how is it done from the database?
The image is stored as a blobfield.
Hi,
How can I load an JPG-image from a database and right-align it in the header of a WPRichText?
Please give me the exact code on how to do this.
Regards,
Stef