RDLC 报告比例图像对齐
我正在制作 RDLC 报告,我使用数据库图像,并将其大小类型设置为比例,如果图像的大小与边框不完全相同,则边框不适合..这是可以的,但是图像将根据边框在左上角对齐,而我需要它居中(在 PDF 上),而在 IE 上它居中..,这里是图像示例,,请我需要帮助..
这是我已经拥有了 http://up.g4z4.com/uploads/f1fdee3542.jpg
这个是理想的人 http://up.g4z4.com/uploads/a3d2ca5b8e.jpg
我读过一次RDLC 报告中的图像来源或注册点位于左上角,这就是为什么它显示为这样的原因..但是写此信息的人说他不确定..这可能吗?或者它与无法更改的默认对齐方式有关?
谢谢你,
I'm working on an RDLC Report ,I use a DB Image, and set it's size type to Proportional, if the image isn't the exact size as it's borders, borders won't fit .. this is ok, but the image will be aligned top-left according to borders while I need it to be centered (on PDF) while on IE it's centered .., here are image examples,, Please I Need Help for this ..
This is the I Already Have
http://up.g4z4.com/uploads/f1fdee3542.jpg
This is the Desired One
http://up.g4z4.com/uploads/a3d2ca5b8e.jpg
I read once that the image origin or Registration Point in RDLC Reports is on the top left, that's why it shows like this .. but the one who wrote that said he's not sure about it .. is this possible? or is it related to a default alignment that can't be changed?
Thank you,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于每个图像,我们可以找出其宽高比或高度/宽度。
假设您的单元格已知宽度和高度,您可以确定它是否太窄或太短。此外,您可以使用以下公式计算其新宽度和高度:
newWidth = cellheight*oldwidth/oldheight
newHeight = cellwidth*oldheight/oldwidth
CellWidth - NewWidth = 2x PaddingLeft
CellHeight - NewHeight = 2x PaddingTop
因此,您现在所需要做的就是将结果除以 2 并将其转换为整数。
我在主报告的 SubReportProcessing 事件中为数据库中的每个图像实现了以下 getter(我实际上是从 sqlite 数据库中提取这些图像),我只需将所有图像添加为数据源。
完成该操作后,我现在可以在图像属性下设置填充值,如下所示:
希望有帮助!
干杯;)
For every image we can find out its aspect ratio either width/height or height/width.
Assuming that your cell has known width and height you can determine if its going to be too narrow or too short. Moreover you can calculate its new width and height with following formulas:
newWidth = cellheight*oldwidth/oldheight
newHeight = cellwidth*oldheight/oldwidth
CellWidth - NewWidth = 2x PaddingLeft
CellHeight - NewHeight = 2x PaddingTop
So all you need to do now is just divide the result by 2 and cast it onto an integer.
I implemented following getters for each image in database(I am actually pulling these images from sqlite database) in the SubReportProcessing Event for my main report I simply add all my images as DataSource.
After that operation I can now set padding value under image properties as follows:
Hope that helps!
Cheers ;)
我也在寻找这个问题的答案;我发现这段代码< /a> 可以解决这个问题(它可以工作),但它不是很通用(取决于硬编码的页面宽度)。只需做一点工作,这段代码就可以工作。
I'm looking for an answer to this as well; I found this code which does the trick (it works) but it's not very generic (depends on a hard coded page width). With a little work this code could work.