Page 1 of 2
[solved] Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Mon Jun 27, 2022 5:26 am
by edwinyzh
The steps that caused the issue:
- Insert a picture.
- set its size to 80%
- export to .docx
- you'll find the the picture enlarged to something like 500% or 1000%. In short, very large.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Mon Jun 27, 2022 8:30 am
by Sergey Tkachenko
I cannot reproduce this problem.
Please send me an RVF file with a scaled picture for testing.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Mon Jun 27, 2022 10:30 am
by edwinyzh
Is XML OK? You know, I use XML.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Mon Jun 27, 2022 10:43 am
by edwinyzh
Additional info - the issue happens with content added with `TRichViewXml.AppendFromStream`.
Maybe this is cause?
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Mon Jun 27, 2022 12:38 pm
by Sergey Tkachenko
Please give me step-by-step instructions how to reproduce this problem.
I cannot reproduce it myself: I tried saving and loading to DocX and RichViewXML, scaled pictures were OK in the both of them.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Mon Jun 27, 2022 2:44 pm
by edwinyzh
When I can construct a test program/code I'll provide it to you.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 10:11 am
by edwinyzh
New finding:
The wrong image size seems to be happening inside TRichViewEdit but not after exporting to Word.
If the png image is not resized, the savec xml is like:
Code: Select all
<image spacing="0" class="TPngImage" img="89504E470D0A1A0A0000000D4948....
But if I reduce its size with mouse drag-and-drop inside TRichViewEdit, after saving to xml, the related xml code is like:
Code: Select all
<image spacing="0" width="9127" height="3578" class="TPngImage" img="89504E470D0A1A0A0000000D4948...
As a result, after reloaded to TRichViewEdit, the image is very large!
Note, the original image size is 656x257
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 10:44 am
by edwinyzh
More findings - the image size is already wrong in `TRVGraphicItemInfo.SetExtraIntProperty`.
If you check the call stack produced by the IDE debugger, 9404 is the calculated new image width which is wrong - I reduced the size of a 656x257 image and the new width couldn't be 9404:
Code: Select all
RVItem.TRVGraphicItemInfo.SetExtraIntProperty(???,9404)
RVItem.TCustomRVItemInfo.SetExtraIntPropertyEx(14981552,???)
CRVData.TCustomRVData.SetItemExtraIntPropertyEx(4,3,9404)
RVERVData.TRVEditRVData.Do_ExtraIntProperty(4,3,9404,rvrfNormal)
RVEdit.TCustomRichViewEdit.SetItemExtraIntPropertyExEd(4,3,9404,False)
RVEdit.TCustomRichViewEdit.SetItemExtraIntPropertyEd(???,???,9404,False)
RVERVData.TRVEditRVData.ResizeItem(4,???,333)
RVERVData.TRVEditRVData.MouseUp(mbLeft,[],52,401)
RichView.TCustomRichView.MouseUp(mbLeft,[],13176640,401)
Vcl.Controls.TControl.DoMouseUp((514, (), 0, (), 52, 401, (), (52, 401), (), 0),(out of bound) 116)
Vcl.Controls.TControl.WMLButtonUp((514, (), 0, (), 52, 401, (), (52, 401), (), 0))
Vcl.Controls.TControl.WndProc((514, 0, 26279988, 0, 0, 0, (), 52, 401, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((514, 0, 26279988, 0, 0, 0, (), 52, 401, (), 0, 0, ()))
RichView.TCustomRichView.WndProc((514, 0, 26279988, 0, 0, 0, (), 52, 401, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(1970246,514,0,26279988)
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 10:57 am
by edwinyzh
More finding:
Maybe `TRVEditRVData.ResizeItem` or TRichViewXml mixed up pixels and twips?
You know, I set all units as twips for all TRichView components.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 12:15 pm
by Sergey Tkachenko
It looks like I understand the problem.
Do you save XML without styles?
In this case, none of TRVStyle properties are saved in XML, including TRVStyle.Units.
Because of this, TRichViewXML does not know that values are saved in twips, loads them as pixels and they become too large.
I'll provide a fix today.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 1:14 pm
by Sergey Tkachenko
See the updated RichViewXML files in
https://www.trichview.com/forums/viewto ... 172#p41172
In this update, RVStyle.Units are saved even if other TRVStyle properties are not saved.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 2:46 pm
by edwinyzh
Sergey Tkachenko wrote: ↑Wed Jun 29, 2022 12:15 pm
It looks like I understand the problem.
Do you save XML without styles?
No, TRichViewXml.SaveStyles is False in my case.
I'll try you rvxml fixes, I appreciate your quick fixes!
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 2:56 pm
by Sergey Tkachenko
edwinyzh wrote: ↑Wed Jun 29, 2022 2:46 pm
No, TRichViewXml.SaveStyles is False in my case.
This is the reason of this problem: in the previous version, if SaveStyles = False, measure units were not saved in XML.
Unfortunately, since the problem was in saving. not in loading, this change does not help with files that were saved previously.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 3:01 pm
by edwinyzh
This issue's fixed with your latest updates, thank you!
Re: [solved] Picture set to 80% but become very very large after exported to .docx or .rtf
Posted: Wed Jun 29, 2022 3:07 pm
by Sergey Tkachenko
I've made a small correction, and uploaded new files to
https://www.trichview.com/support/files ... xmlpas.zip
There was a bug: if RvXML.StyleLoadingMode <> slmIgnore, and XML file was saved without styles but with measure units, RvXML might think that this XML contains 0 styles (instead of "this XML was saved without styles")