Hello, I have a problem with the TAdvRichEditor component. When I go to use the .merge function with the images they are imported with enormous dimensions compared to the height and width that I have set on the page. (297mm, 210mm). How can I adjust the size of the images?
Thank you in advance for your help.
Luigi
// my code
try
pfirmaPaz.LoadFromFile(sTemp_Folder + '' + 'sign_paz.jpg');
plogo.LoadFromFile(sTemp_Folder + '' + 'logo_300_60.jpg');
// pfirmaDot.LoadFromFile('.\temp_sign_dot.jpg');
slCampi := TStringList.Create;
slCampi.AddObject('jd_logo_int=', plogo);
slCampi.AddObject('jd_fg_paz=', pfirmaPaz);
// slCampi.AddObject('jd_fg_dot=', pfirmaDot);
main_rtf_doc_editor.Merge(slCampi);
finally
slCampi.Free;
end;
For image merge, the original image size is used. There is at this moment unfortunately not a built-in functionality to preset the image size to a different size than the original image size.
I'd suggest to resize your images before doing the merge, for example in a separate DB field.
Thanks for the answer and for the suggestion, I tried the solution you indicated and in fact by reducing the size of the image you can make it fit in the document.
However, the necessary reduction is such that the image quality is lost in my case a logo that I had to reduce to the width of 100 pixels.
To check I did a test by importing the image in libre office and in word; comparing the result I understood that, when your compose TAdvRichEditor performs a merge with an image, it sets a size much larger than its real size. If necessary, I can send the test files and exports in pdf.
Thanks for the support.
Luigi
TAdvRichEditor will need to be extended if it will be necessary to somehow query what the final size should become. I understand you want to dynamically set the size or how otherwise do you wish to specify the final size?
Hi, I believe the TMSAdvRichEdito component should behave like other RTF editors.
I did a comparison test with RTF files in MS Word, Libre Office Write and the TMSAdvRichEditor component.To do this I have modified your demo software to perform a merge with the same jpg file used with the other editors.
procedure TForm1.Button1Click(Sender: TObject);
Var
iPos: Integer;
slCampi: TStringList;
logo_merge : TPicture;
begin
AdvRichEditor1.Clear;
AdvRichEditor1.AddText('logo_merge');
AdvRichEditor1.GotoTextBegin;
AdvRichEditor1.Find('logo_merge');
AdvRichEditor1.SelectWordAtCaret;
AdvRichEditor1.SetSelectionMergeField('logo_merge');
try
AdvRichEditor1.UnMerge;
logo_merge := TPicture.Create;
logo_merge.LoadFromFile('.\logo_merge.jpg');
slCampi := TStringList.Create;
slCampi.AddObject('logo_merge=', logo_merge);
AdvRichEditor1.Merge(slCampi);
finally
slCampi.Free;
logo_merge.Free;
end;
end;
The test consisted of inserting a JPG image (200x200px) into an RTF file.
In the link you will find all documents from test. https://drive.google.com/drive/folders/1Php_xD1bLH0FDQkRYAVIfWOvbAYEFVDt?usp=sharing
MS Word and LO Write insert the image in the correct size while the TMS component inserts the image more than twice the size of other software.
Using TMSAdvRichEdito the size of the image is too large whether you are using the insert image function or whether you are using the merge function.
In my opinion the component should be modified so that it inserts images with dimensions equivalent to those of the other RTF editors.
Thanks for collaboration.
Greetings