[solved] Picture set to 80% but become very very large after exported to .docx or .rtf
[solved] Picture set to 80% but become very very large after exported to .docx or .rtf
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.
- 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.
Last edited by edwinyzh on Wed Jun 29, 2022 3:01 pm, edited 1 time in total.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
I cannot reproduce this problem.
Please send me an RVF file with a scaled picture for testing.
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
Is XML OK? You know, I use XML.
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
Additional info - the issue happens with content added with `TRichViewXml.AppendFromStream`.
Maybe this is cause?
Maybe this is cause?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
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.
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
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
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:
But if I reduce its size with mouse drag-and-drop inside TRichViewEdit, after saving to xml, the related xml code is like:
As a result, after reloaded to TRichViewEdit, the image is very large!
Note, the original image size is 656x257
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....
Code: Select all
<image spacing="0" width="9127" height="3578" class="TPngImage" img="89504E470D0A1A0A0000000D4948...
Note, the original image size is 656x257
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
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:
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
More finding:
Maybe `TRVEditRVData.ResizeItem` or TRichViewXml mixed up pixels and twips?
You know, I set all units as twips for all TRichView components.
Maybe `TRVEditRVData.ResizeItem` or TRichViewXml mixed up pixels and twips?
You know, I set all units as twips for all TRichView components.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
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.
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.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
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.
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
No, TRichViewXml.SaveStyles is False in my case.Sergey Tkachenko wrote: ↑Wed Jun 29, 2022 12:15 pm It looks like I understand the problem.
Do you save XML without styles?
I'll try you rvxml fixes, I appreciate your quick fixes!
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Picture set to 80% but become very very large after exported to .docx or .rtf
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
This issue's fixed with your latest updates, thank you!
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: [solved] Picture set to 80% but become very very large after exported to .docx or .rtf
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")
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")