I want to modify a PDF document, that I get in form of a template, but without any EditFields in it, I want to be able to add EditFields and keep the PDF format, is it possible ?
Green Flyer
I want to modify a PDF document, that I get in form of a template, but without any EditFields in it, I want to be able to add EditFields and keep the PDF format, is it possible ?
Green Flyer
I'll work on that and keep you posted on the results.
Is a ReformatAll required for EACH call tp MergeText or just one after all is done ?
TIA,
The little green man
Zitat
please note, MaileMerge does not "replace" fields, it inserts the data after the "insertpoint". (In WPTools 5 it inserts BETWEEN start and end tag)I hope you do not call MergeText for each field, such as MergeText('name'), MergeText('str') etc. That is not a perfect approach and can be the reson no field is merged since the field name ios not found.
Use MergeText('') and check for property inspname in the event.
As I said in a previous post, this is the code that will call the MergeText event, no data manipulation with inspname at this point.
for i:= 0 to FEditor.HeaderFooter.Count - 1 do begin if not (FEditor.HeaderFooter.Items[i].Empty) then begin FEditor.HeaderFooter.Items[i].WorkOnText := True; FEditor.MergeText; end; end; FEditor.WorkOnText := wpBody; FEditor.MergeText;
As for this part of the code
This is just to get the name of the field in the generic query that is associated with the inspname and will have the data that needs to be merged in that position.
I know I'm not that far because when I debug I see that the right values are returned from the generic query, the part I still haven't figured out is why I can't see the values I have inserted in the document.
Is there any options I should make sure are set ?
Am I missing a key Refresh/ReformatAll/ or something else ?
I could create a sample that doesn't involve a database to show you the entire code, so you can see where I make my mistake.
The Little Green_Man
the inspname is used to locate in a DataSet the map to the table-field pair that will contain the data to be inserted in the EditField.
Once it is located it's set to a local var
vFieldName := ParseNomChampsToAlias(dstMotsCles.FieldByName('NOMCHAMP').AsString);
...
Contents.StringValue := qryGeneric.FieldByName(vFieldName).AsString;
qryGeneric, is a TQuery, that has been built dynamically from the list of merge fields found in the current document being asked to merge.
I'm just trying to figure out what part I'm not doing right, because I can't see the values that were used to replace the MergeFields [inspname], but I see the values when debugging, that is returned by the query, but when looking at the end printed result I only see the static text that is in the document.... So that's why I think I'm just missing a small part for it to work ...
I have tried a couple of things but I can't make it work so far...
Any suggestions or questions are welcome.
The little green man
I've create an event that will handle the problem I had in th OP
I can create a List of all the inspname EditFields for the document.
My problem is with the MergeText, I can't seem to figure out what step I'm forgetting ....
for i:= 0 to FEditor.HeaderFooter.Count - 1 do begin if not (FEditor.HeaderFooter.Items[i].Empty) then begin FEditor.HeaderFooter.Items[i].WorkOnText := True; FEditor.MergeText; end; end; FEditor.WorkOnText := wpBody; FEditor.MergeText;
I know I have seen a example on your site, but can't seem to find it, I just can't seem to make the Merge part work, this is the Merge Event
if dstMotsCles.Locate('DESCRIPTION', inspname, []) then
begin
try
// Field in query that contains the data
vFieldName := ParseNomChampsToAlias(dstMotsCles.FieldByName('NOMCHAMP').AsString);
// Content Options, deletes mergefield markers
//Contents.Options := [mmDeleteUntilFieldEnd];
// If the field is a Blob and not null, assign the data directly
if (qryGeneric.FieldByName(vFieldName).IsBlob) then
begin
// Blob is not of sub type text
if qryGeneric.FieldByName(vFieldName).Data.sqlsubtype <> isc_blob_text then
begin
// Insert an blob field image
vObjImage := TWPOImage.Create(FEditor);
vObjImage.FileExtension := 'BMP';
// Assign MemoryStream to TWPOImage object
vObjImage.LoadFromStream(GetBlobStream(vFieldName));
// Save Image for Compare test
if inspname = 'LOGO ETABLISSEMENT' then
vObjImage.SaveToFile(LOGO_FILE);
// Size of image
//vObjImage.WidthTW := vObjImage.ContentsWidth;
//vObjImage.HeightTW := vObjImage.ContentsHeight;
// If already replaced don't do nothing
if Contents.CurrentObject = nil then
begin
Contents.Options := Contents.Options + [mmInsertObject];
Contents.Obj := vObjImage;
end;
end
else
begin
vBlobText := TStringList.Create;
if qryGeneric.BlobToStrings(vFieldName, vBlobText) then
Contents.StringValue := vBlobText.Text;
end;
end
else
begin
try
Contents.StringValue := qryGeneric.FieldByName(vFieldName).AsString;
except
end;
end;
except
//Contents.Options := Contents.Options - [mmDeleteUntilFieldEnd];
end;
end;
end;
Alles anzeigen
TIA, for the help and suggestions...
the Little green man
Hi Julian,
Is there a way in the WP4 top get the list of the merge fields in a single method like in WP5:
CodeListTags(wpobjMergeField, '*ALL*', True)
Or do I have to loop through all the Fields, that I "Find"
Thanks
The little green man
Hello again,
I was working with tables and was trying to create an "Odd" and "Even" style for each row defined as such:
// Set Table Styles
with FEditor.ParStyles.AddStyle('Even') do
begin
ASet(WPAT_IndentLeft, 32);
ASet(WPAT_IndentRight, 32);
ASet(WPAT_CharStyleON, WPSTY_ITALIC);
ASet(WPAT_CharStyleMask, 1);
ASetColor(WPAT_BGColor, clMoneyGreen);
ASet(WPAT_ShadingValue, 30);
end;
with Feditor.ParStyles.AddStyle('Odd') do
begin
ASet(WPAT_IndentLeft, 32);
ASet(WPAT_IndentRight, 32);
ASet(WPAT_CharStyleON, WPSTY_BOLD);
ASet(WPAT_CharStyleMask, 1);
ASetColor(WPAT_BGColor, clCream);
ASet(WPAT_ShadingValue, 90);
end;
Alles anzeigen
Helas, I'm able to get the Odd rows text to be BOLD, but the Even rows are not in Italic in any way. I'm looking around trying to find if something was posted on this matter ... BTW, changing Italic to Bold in the Even style will work ....
Green_Flyer
Actually, I based my test code on that example, except I don't get the same results as you ....
That's why I was wondering if there was any other options, parameters or whatever that needs to be set to obtain the same results as your demo.
The only difference that I see, is that your text is already set, I have to get it from a database, but don't feel that should change anything ....
And yes I can't erase the text in your EditField demo...
Will keep on looking in your demo, I most have missed something.
But if you think of something to check that is required to obtain the same results as you, well post it, if I find I'll tell you what I forgot
TIA,
Green_Flyer
Does anyone have a clue, on how this part is supposed to work with forms at all ???
Julian to the rescue ... just like Mighty mouse ?
Is this the only property you have to set, to enable the protection of Form text that has form fields in it. I have tried a couple of combinations and either that I can't enter any text at all, with the property set like the title.
If I comment out the line, then I can enter values for the FormFields, but I can erase the preformatted text and we don't want them to be able to do that
FEditor.ProtectedProp := [ppAllExceptForEditFields];
FEditor.EditOptionsEx := [wpTABMovesToNextEditField, wpRepaintOnFieldMove];
FEditor.InsertPointAttr.Hidden := True;
After more testing, the text on the form can be selected and deleted, which can't be allowed in the specs that I have, if the ProtectedProp was assigned the value or not.
TIA,
Green_Flyer
I don't know why it wasn't straight forward as you say it should be, all I wanted to mention was the steps that I had to do to make it work.
Although, I'm new here and the person that was responsible for Wptools is no longer here, so maybe they did change the runtime librairies, I don't know but there was clearly an issue of referencing obsolete files in the runtimes files that was causing the messages that I got, when trying to install the new version of WPTools.
Zitat
However, something doesn't seem right. You shouldn't have to do any of that hoop-jumping, at all. There should be no Version 4 dependencies, be it WPTools4D[x]_RT.dcp or anything else V4-related, either in the demo or the licensed version.
I just think that there might have been references left towards the version 4 component in Delphi somewhere that was causing me problems.
The important thing is that I can install the package to test ...
Green_Flyer
Finally, I got it to work ....
The main problem was that WPTools5, needs the WPTools4D[x]_RT.dcp to compile and install. Except that, most files in the WPTools4D[x]_RT package are now obsolete, and will give the messages mentionned in previous posts.
But before I needed to repackage the WPShared_D7_RT, and make sure it linked to the files in the version 5 folder.
After Modify the WPTools4d[x]_RT.dpk so it contains only the following files and links to the new version of WPShared_D7_RT:
=> WPPrTab1
=> WPRTEDefs
The other DCU's will get implicitly compiled. I didn't find that package in the zip install files from your site, it would be easier if it was included, with the right files in it already ...
Green_Flyer
I did in fact have the reference there, but alas it didn't change the end result. I reextracted the source files, opened the WPTools5_D7.dpk.
First compile, only warnings, press ok.
Dialogue box, for changes that are required for the package ... ok again, recompiles and then this message:
WPTools4D7_RT, not found, so I add to the search path towards the location for that file, in the project options for WPTools[5].
Then, well same trouble as original message.
TIA,
Green_Flyer
Every time I try to install the demo for version 5 of WPTools, I receive a message that some files have to be included in the dpk, for it to install properly.
Once, the files are added to the WPTools5_D7.dpk, I get this error message when trying to [install/compile] the package:
Unit WPCtrRich was compiled with a different version of WPPrTab1.WPCreateTableForm....
I have uninstalled the previous package(4) from the component/install new..
Is there other steps that are required to install the version 5 of the WPTools component.
TIA,
Green_Flyer
Thanks for the reply Julian, I will be looking at the version 5 of your product.
Green_Flyer
I can't seem to find why there is a delay between the end-user pressing a Key and for the Char to appear on the screen.
Depending on the situation, we can get up to five chars behind what the user is typing. There is also lots of flickering while typing.
I just started a new job and this is my first task, so if you're missing critical information to help me out, just ask ...
TIA,
Green_Flyer